diff --git a/acl/src/main/java/org/springframework/security/acls/AclEntryVoter.java b/acl/src/main/java/org/springframework/security/acls/AclEntryVoter.java index 3b0205c9e8..8b5a4a76f8 100644 --- a/acl/src/main/java/org/springframework/security/acls/AclEntryVoter.java +++ b/acl/src/main/java/org/springframework/security/acls/AclEntryVoter.java @@ -80,7 +80,6 @@ import org.springframework.util.StringUtils; *

All comparisons and prefixes are case sensitive.

* * @author Ben Alex - * @version $Id$ */ public class AclEntryVoter extends AbstractAclVoter { //~ Static fields/initializers ===================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/AclPermissionEvaluator.java b/acl/src/main/java/org/springframework/security/acls/AclPermissionEvaluator.java index 4c550e8fed..f9f4014a63 100644 --- a/acl/src/main/java/org/springframework/security/acls/AclPermissionEvaluator.java +++ b/acl/src/main/java/org/springframework/security/acls/AclPermissionEvaluator.java @@ -28,7 +28,6 @@ import org.springframework.security.core.Authentication; * {@link org.springframework.security.acls.AclEntryVoter AclEntryVoter}. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class AclPermissionEvaluator implements PermissionEvaluator { diff --git a/acl/src/main/java/org/springframework/security/acls/afterinvocation/AbstractAclProvider.java b/acl/src/main/java/org/springframework/security/acls/afterinvocation/AbstractAclProvider.java index 3b52699235..6e0f0caaa8 100644 --- a/acl/src/main/java/org/springframework/security/acls/afterinvocation/AbstractAclProvider.java +++ b/acl/src/main/java/org/springframework/security/acls/afterinvocation/AbstractAclProvider.java @@ -39,7 +39,6 @@ import org.springframework.util.Assert; * Abstract {@link AfterInvocationProvider} which provides commonly-used ACL-related services. * * @author Ben Alex - * @version $Id$ */ public abstract class AbstractAclProvider implements AfterInvocationProvider { //~ Instance fields ================================================================================================ diff --git a/acl/src/main/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationCollectionFilteringProvider.java b/acl/src/main/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationCollectionFilteringProvider.java index 7de76111aa..a86081a3c6 100644 --- a/acl/src/main/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationCollectionFilteringProvider.java +++ b/acl/src/main/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationCollectionFilteringProvider.java @@ -57,7 +57,6 @@ import org.springframework.security.core.Authentication; * * @author Ben Alex * @author Paulo Neves - * @version $Id$ */ public class AclEntryAfterInvocationCollectionFilteringProvider extends AbstractAclProvider { //~ Static fields/initializers ===================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/afterinvocation/ArrayFilterer.java b/acl/src/main/java/org/springframework/security/acls/afterinvocation/ArrayFilterer.java index 156592df39..afcd950c71 100644 --- a/acl/src/main/java/org/springframework/security/acls/afterinvocation/ArrayFilterer.java +++ b/acl/src/main/java/org/springframework/security/acls/afterinvocation/ArrayFilterer.java @@ -30,7 +30,6 @@ import org.apache.commons.logging.LogFactory; * * @author Ben Alex * @author Paulo Neves - * @version $Id$ */ class ArrayFilterer implements Filterer { //~ Static fields/initializers ===================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/afterinvocation/CollectionFilterer.java b/acl/src/main/java/org/springframework/security/acls/afterinvocation/CollectionFilterer.java index db0474b4f5..475b74d0a1 100644 --- a/acl/src/main/java/org/springframework/security/acls/afterinvocation/CollectionFilterer.java +++ b/acl/src/main/java/org/springframework/security/acls/afterinvocation/CollectionFilterer.java @@ -29,7 +29,6 @@ import java.util.Set; * * @author Ben Alex * @author Paulo Neves - * @version $Id$ */ class CollectionFilterer implements Filterer { //~ Static fields/initializers ===================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/afterinvocation/Filterer.java b/acl/src/main/java/org/springframework/security/acls/afterinvocation/Filterer.java index ae7f3f107e..9c7f685ac0 100644 --- a/acl/src/main/java/org/springframework/security/acls/afterinvocation/Filterer.java +++ b/acl/src/main/java/org/springframework/security/acls/afterinvocation/Filterer.java @@ -23,7 +23,6 @@ import java.util.Iterator; * * @author Ben Alex * @author Paulo Neves - * @version $Id$ */ interface Filterer extends Iterable { //~ Methods ======================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/domain/AccessControlEntryImpl.java b/acl/src/main/java/org/springframework/security/acls/domain/AccessControlEntryImpl.java index 4729631307..0fb3287faa 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/AccessControlEntryImpl.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/AccessControlEntryImpl.java @@ -29,7 +29,6 @@ import java.io.Serializable; * An immutable default implementation of AccessControlEntry. * * @author Ben Alex - * @version $Id$ */ public class AccessControlEntryImpl implements AccessControlEntry, AuditableAccessControlEntry { //~ Instance fields ================================================================================================ @@ -77,7 +76,7 @@ public class AccessControlEntryImpl implements AccessControlEntry, AuditableAcce if (rhs.getAcl() == null) { return false; } - + // Both this.acl and rhs.acl are non-null, so do a comparison if (this.acl.getObjectIdentity() == null) { if (rhs.acl.getObjectIdentity() != null) { @@ -91,7 +90,7 @@ public class AccessControlEntryImpl implements AccessControlEntry, AuditableAcce } } } - + if (this.id == null) { if (rhs.id != null) { return false; @@ -108,7 +107,7 @@ public class AccessControlEntryImpl implements AccessControlEntry, AuditableAcce return false; } } - + if ((this.auditFailure != rhs.isAuditFailure()) || (this.auditSuccess != rhs.isAuditSuccess()) || (this.granting != rhs.isGranting()) || !this.permission.equals(rhs.getPermission()) || !this.sid.equals(rhs.getSid())) { diff --git a/acl/src/main/java/org/springframework/security/acls/domain/AclAuthorizationStrategy.java b/acl/src/main/java/org/springframework/security/acls/domain/AclAuthorizationStrategy.java index 0ef2021fe7..a5cfcbd253 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/AclAuthorizationStrategy.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/AclAuthorizationStrategy.java @@ -23,7 +23,6 @@ import org.springframework.security.acls.model.Acl; * adminstrative methods on the AclImpl. * * @author Ben Alex - * @version $Id$ */ public interface AclAuthorizationStrategy { //~ Static fields/initializers ===================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/domain/AclAuthorizationStrategyImpl.java b/acl/src/main/java/org/springframework/security/acls/domain/AclAuthorizationStrategyImpl.java index 8022a7b038..eb06f315d3 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/AclAuthorizationStrategyImpl.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/AclAuthorizationStrategyImpl.java @@ -37,7 +37,6 @@ import org.springframework.util.Assert; * {@link GrantedAuthority} and injected into the constructor. * * @author Ben Alex - * @version $Id$ */ public class AclAuthorizationStrategyImpl implements AclAuthorizationStrategy { //~ Instance fields ================================================================================================ diff --git a/acl/src/main/java/org/springframework/security/acls/domain/AclFormattingUtils.java b/acl/src/main/java/org/springframework/security/acls/domain/AclFormattingUtils.java index c5b0362c01..668b4b4b3f 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/AclFormattingUtils.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/AclFormattingUtils.java @@ -22,7 +22,6 @@ import org.springframework.util.Assert; * Utility methods for displaying ACL information. * * @author Ben Alex - * @version $Id$ */ public abstract class AclFormattingUtils { diff --git a/acl/src/main/java/org/springframework/security/acls/domain/AclImpl.java b/acl/src/main/java/org/springframework/security/acls/domain/AclImpl.java index d7f4040fe5..38687b1634 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/AclImpl.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/AclImpl.java @@ -35,7 +35,6 @@ import org.springframework.util.Assert; * Base implementation of Acl. * * @author Ben Alex - * @version $Id$ */ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl { //~ Instance fields ================================================================================================ diff --git a/acl/src/main/java/org/springframework/security/acls/domain/AuditLogger.java b/acl/src/main/java/org/springframework/security/acls/domain/AuditLogger.java index c882202272..e233cfa99e 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/AuditLogger.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/AuditLogger.java @@ -21,7 +21,6 @@ import org.springframework.security.acls.model.AccessControlEntry; * Used by AclImpl to log audit events. * * @author Ben Alex - * @version $Id$ * */ public interface AuditLogger { diff --git a/acl/src/main/java/org/springframework/security/acls/domain/BasePermission.java b/acl/src/main/java/org/springframework/security/acls/domain/BasePermission.java index 83a0252c18..a1fe8f0fb1 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/BasePermission.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/BasePermission.java @@ -26,7 +26,6 @@ import org.springframework.security.acls.model.Permission; *

* * @author Ben Alex - * @version $Id$ */ public class BasePermission extends AbstractPermission { public static final Permission READ = new BasePermission(1 << 0, 'R'); // 1 diff --git a/acl/src/main/java/org/springframework/security/acls/domain/ConsoleAuditLogger.java b/acl/src/main/java/org/springframework/security/acls/domain/ConsoleAuditLogger.java index cd099f54d1..5c0b059b02 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/ConsoleAuditLogger.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/ConsoleAuditLogger.java @@ -24,7 +24,6 @@ import org.springframework.util.Assert; * A basic implementation of {@link AuditLogger}. * * @author Ben Alex - * @version $Id$ */ public class ConsoleAuditLogger implements AuditLogger { //~ Methods ======================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/domain/CumulativePermission.java b/acl/src/main/java/org/springframework/security/acls/domain/CumulativePermission.java index 888e89a1cd..554989dabf 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/CumulativePermission.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/CumulativePermission.java @@ -19,11 +19,10 @@ import org.springframework.security.acls.model.Permission; /** * Represents a Permission that is constructed at runtime from other permissions. - * + * *

Methods return this, in order to facilitate method chaining.

* * @author Ben Alex - * @version $Id$ */ public class CumulativePermission extends AbstractPermission { @@ -32,7 +31,7 @@ public class CumulativePermission extends AbstractPermission { public CumulativePermission() { super(0, ' '); } - + public CumulativePermission clear(Permission permission) { this.mask &= ~permission.getMask(); this.pattern = AclFormattingUtils.demergePatterns(this.pattern, permission.getPattern()); @@ -46,14 +45,14 @@ public class CumulativePermission extends AbstractPermission { return this; } - + public CumulativePermission set(Permission permission) { this.mask |= permission.getMask(); this.pattern = AclFormattingUtils.mergePatterns(this.pattern, permission.getPattern()); return this; } - + public String getPattern() { return this.pattern; } diff --git a/acl/src/main/java/org/springframework/security/acls/domain/EhCacheBasedAclCache.java b/acl/src/main/java/org/springframework/security/acls/domain/EhCacheBasedAclCache.java index e1987e387f..4b16770162 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/EhCacheBasedAclCache.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/EhCacheBasedAclCache.java @@ -36,7 +36,6 @@ import org.springframework.util.Assert; *

* * @author Ben Alex - * @version $Id$ */ public class EhCacheBasedAclCache implements AclCache { //~ Instance fields ================================================================================================ diff --git a/acl/src/main/java/org/springframework/security/acls/domain/GrantedAuthoritySid.java b/acl/src/main/java/org/springframework/security/acls/domain/GrantedAuthoritySid.java index db81b926b7..0bb056d182 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/GrantedAuthoritySid.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/GrantedAuthoritySid.java @@ -26,7 +26,6 @@ import org.springframework.util.Assert; * wish to provide an alternative Sid implementation that uses some other identifier.

* * @author Ben Alex - * @version $Id$ */ public class GrantedAuthoritySid implements Sid { //~ Instance fields ================================================================================================ diff --git a/acl/src/main/java/org/springframework/security/acls/domain/IdentityUnavailableException.java b/acl/src/main/java/org/springframework/security/acls/domain/IdentityUnavailableException.java index 20cbea99e5..18e7383c42 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/IdentityUnavailableException.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/IdentityUnavailableException.java @@ -18,7 +18,6 @@ package org.springframework.security.acls.domain; * Thrown if an ACL identity could not be extracted from an object. * * @author Ben Alex - * @version $Id$ */ public class IdentityUnavailableException extends RuntimeException { //~ Constructors =================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/domain/ObjectIdentityImpl.java b/acl/src/main/java/org/springframework/security/acls/domain/ObjectIdentityImpl.java index 4c66207630..f805679c31 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/ObjectIdentityImpl.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/ObjectIdentityImpl.java @@ -29,7 +29,6 @@ import org.springframework.util.ClassUtils; * reflection to build the identity information. * * @author Ben Alex - * @version $Id$ */ public class ObjectIdentityImpl implements ObjectIdentity { //~ Instance fields ================================================================================================ diff --git a/acl/src/main/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImpl.java b/acl/src/main/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImpl.java index 85a5f34e9e..8854f2c65c 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImpl.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImpl.java @@ -26,7 +26,6 @@ import org.springframework.security.acls.model.ObjectIdentityRetrievalStrategy; * that uses the constructors of {@link ObjectIdentityImpl} to create the {@link ObjectIdentity}. * * @author Ben Alex - * @version $Id$ */ public class ObjectIdentityRetrievalStrategyImpl implements ObjectIdentityRetrievalStrategy, ObjectIdentityGenerator { //~ Methods ======================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/domain/PrincipalSid.java b/acl/src/main/java/org/springframework/security/acls/domain/PrincipalSid.java index 56d38c3b6a..db59ac626f 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/PrincipalSid.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/PrincipalSid.java @@ -28,7 +28,6 @@ import org.springframework.util.Assert; * objects may wish to provide an alternative Sid implementation that uses some other identifier.

* * @author Ben Alex - * @version $Id$ */ public class PrincipalSid implements Sid { //~ Instance fields ================================================================================================ diff --git a/acl/src/main/java/org/springframework/security/acls/domain/SidRetrievalStrategyImpl.java b/acl/src/main/java/org/springframework/security/acls/domain/SidRetrievalStrategyImpl.java index 2604057585..afed23cd77 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/SidRetrievalStrategyImpl.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/SidRetrievalStrategyImpl.java @@ -35,7 +35,6 @@ import org.springframework.util.Assert; * The returned array will always contain the {@link PrincipalSid} before any {@link GrantedAuthoritySid} elements. * * @author Ben Alex - * @version $Id$ */ public class SidRetrievalStrategyImpl implements SidRetrievalStrategy { diff --git a/acl/src/main/java/org/springframework/security/acls/domain/package.html b/acl/src/main/java/org/springframework/security/acls/domain/package.html index 9172c16367..58fd09a56a 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/package.html +++ b/acl/src/main/java/org/springframework/security/acls/domain/package.html @@ -1,5 +1,5 @@ - - -Basic implementation of access control lists (ACLs) interfaces. - - + + +Basic implementation of access control lists (ACLs) interfaces. + + diff --git a/acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java b/acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java index 55821026a2..62ab519dce 100644 --- a/acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java +++ b/acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java @@ -72,7 +72,6 @@ import org.springframework.util.Assert; * generated by the the default values. * * @author Ben Alex - * @version $Id$ */ public final class BasicLookupStrategy implements LookupStrategy { diff --git a/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java b/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java index 35fdb6e9b3..30ba34fcf5 100644 --- a/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java +++ b/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java @@ -43,7 +43,6 @@ import org.springframework.util.Assert; * detect changed parameters easily. * * @author Ben Alex - * @version $Id$ */ public class JdbcAclService implements AclService { //~ Static fields/initializers ===================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcMutableAclService.java b/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcMutableAclService.java index 69a7b7d536..b8693fd8aa 100644 --- a/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcMutableAclService.java +++ b/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcMutableAclService.java @@ -56,7 +56,6 @@ import org.springframework.util.Assert; * * @author Ben Alex * @author Johannes Zlattinger - * @version $Id$ */ public class JdbcMutableAclService extends JdbcAclService implements MutableAclService { //~ Instance fields ================================================================================================ diff --git a/acl/src/main/java/org/springframework/security/acls/jdbc/LookupStrategy.java b/acl/src/main/java/org/springframework/security/acls/jdbc/LookupStrategy.java index d709b72dbb..9a11599627 100644 --- a/acl/src/main/java/org/springframework/security/acls/jdbc/LookupStrategy.java +++ b/acl/src/main/java/org/springframework/security/acls/jdbc/LookupStrategy.java @@ -27,7 +27,6 @@ import java.util.Map; * Performs lookups for {@link org.springframework.security.acls.model.AclService}. * * @author Ben Alex - * @version $Id$ */ public interface LookupStrategy { //~ Methods ======================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/jdbc/package.html b/acl/src/main/java/org/springframework/security/acls/jdbc/package.html index adbee4c539..e0190860d7 100644 --- a/acl/src/main/java/org/springframework/security/acls/jdbc/package.html +++ b/acl/src/main/java/org/springframework/security/acls/jdbc/package.html @@ -1,5 +1,5 @@ - - -JDBC-based persistence of ACL information. - - + + +JDBC-based persistence of ACL information. + + diff --git a/acl/src/main/java/org/springframework/security/acls/model/AccessControlEntry.java b/acl/src/main/java/org/springframework/security/acls/model/AccessControlEntry.java index 4f7caa8ba2..5c157d46a5 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/AccessControlEntry.java +++ b/acl/src/main/java/org/springframework/security/acls/model/AccessControlEntry.java @@ -27,7 +27,6 @@ import java.io.Serializable; *

* * @author Ben Alex - * @version $Id$ * */ public interface AccessControlEntry extends Serializable { diff --git a/acl/src/main/java/org/springframework/security/acls/model/Acl.java b/acl/src/main/java/org/springframework/security/acls/model/Acl.java index a7c8c91464..7946e0b388 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/Acl.java +++ b/acl/src/main/java/org/springframework/security/acls/model/Acl.java @@ -31,7 +31,7 @@ import java.util.List; *

* *

- * Implementing classes may elect to return instances that represent + * Implementing classes may elect to return instances that represent * {@link org.springframework.security.acls.model.Permission} information for either * some OR all {@link org.springframework.security.acls.model.Sid} * instances. Therefore, an instance may NOT necessarily contain ALL Sids @@ -39,23 +39,22 @@ import java.util.List; *

* * @author Ben Alex - * @version $Id$ */ public interface Acl extends Serializable { /** * Returns all of the entries represented by the present Acl. Entries associated with * the Acl parents are not returned. - * + * *

This method is typically used for administrative purposes.

- * + * *

The order that entries appear in the array is important for methods declared in the * {@link MutableAcl} interface. Furthermore, some implementations MAY use ordering as * part of advanced permission checking.

- * + * *

Do NOT use this method for making authorization decisions. Instead use {@link * #isGranted(List, List, boolean)}.

- * + * *

This method must operate correctly even if the Acl only represents a subset of * Sids. The caller is responsible for correctly handling the result if only a subset of * Sids is represented.

@@ -84,11 +83,11 @@ public interface Acl extends Serializable { /** * A domain object may have a parent for the purpose of ACL inheritance. If there is a parent, its ACL can * be accessed via this method. In turn, the parent's parent (grandparent) can be accessed and so on. - * + * *

This method solely represents the presence of a navigation hierarchy between the parent Acl and this * Acl. For actual inheritance to take place, the {@link #isEntriesInheriting()} must also be * true.

- * + * *

This method must operate correctly even if the Acl only represents a subset of * Sids. The caller is responsible for correctly handling the result if only a subset of * Sids is represented.

@@ -111,13 +110,13 @@ public interface Acl extends Serializable { /** * This is the actual authorization logic method, and must be used whenever ACL authorization decisions are * required. - * + * *

An array of Sids are presented, representing security identifies of the current * principal. In addition, an array of Permissions is presented which will have one or more bits set * in order to indicate the permissions needed for an affirmative authorization decision. An array is presented * because holding any of the Permissions inside the array will be sufficient for an * affirmative authorization.

- * + * *

The actual approach used to make authorization decisions is left to the implementation and is not * specified by this interface. For example, an implementation MAY search the current ACL in the order * the ACL entries have been stored. If a single entry is found that has the same active bits as are shown in a @@ -127,9 +126,9 @@ public interface Acl extends Serializable { * ACL, provided that {@link #isEntriesInheriting()} is true, the authorization decision may be * passed to the parent ACL. If there is no matching entry, the implementation MAY throw an exception, or make a * predefined authorization decision.

- * + * *

This method must operate correctly even if the Acl only represents a subset of Sids, - * although the implementation is permitted to throw one of the signature-defined exceptions if the method + * although the implementation is permitted to throw one of the signature-defined exceptions if the method * is called requesting an authorization decision for a {@link Sid} that was never loaded in this Acl. *

* diff --git a/acl/src/main/java/org/springframework/security/acls/model/AclCache.java b/acl/src/main/java/org/springframework/security/acls/model/AclCache.java index 26ec76048a..f8ef303838 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/AclCache.java +++ b/acl/src/main/java/org/springframework/security/acls/model/AclCache.java @@ -23,7 +23,6 @@ import java.io.Serializable; * A caching layer for {@link JdbcAclService}. * * @author Ben Alex - * @version $Id$ * */ public interface AclCache { diff --git a/acl/src/main/java/org/springframework/security/acls/model/AclDataAccessException.java b/acl/src/main/java/org/springframework/security/acls/model/AclDataAccessException.java index 167f637b30..110bf22d02 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/AclDataAccessException.java +++ b/acl/src/main/java/org/springframework/security/acls/model/AclDataAccessException.java @@ -4,7 +4,6 @@ package org.springframework.security.acls.model; * Abstract base class for Acl data operations. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public abstract class AclDataAccessException extends RuntimeException { diff --git a/acl/src/main/java/org/springframework/security/acls/model/AclService.java b/acl/src/main/java/org/springframework/security/acls/model/AclService.java index 23ee910f18..80c2c6568f 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/AclService.java +++ b/acl/src/main/java/org/springframework/security/acls/model/AclService.java @@ -23,7 +23,6 @@ import java.util.Map; * Provides retrieval of {@link Acl} instances. * * @author Ben Alex - * @version $Id$ */ public interface AclService { //~ Methods ======================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/model/AlreadyExistsException.java b/acl/src/main/java/org/springframework/security/acls/model/AlreadyExistsException.java index f74a5e2738..a61b1b564a 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/AlreadyExistsException.java +++ b/acl/src/main/java/org/springframework/security/acls/model/AlreadyExistsException.java @@ -19,7 +19,6 @@ package org.springframework.security.acls.model; * Thrown if an Acl entry already exists for the object. * * @author Ben Alex - * @version $Id$ */ public class AlreadyExistsException extends AclDataAccessException { //~ Constructors =================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/model/AuditableAccessControlEntry.java b/acl/src/main/java/org/springframework/security/acls/model/AuditableAccessControlEntry.java index 988aadeb26..e03607ae44 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/AuditableAccessControlEntry.java +++ b/acl/src/main/java/org/springframework/security/acls/model/AuditableAccessControlEntry.java @@ -19,7 +19,6 @@ package org.springframework.security.acls.model; * Represents an ACE that provides auditing information. * * @author Ben Alex - * @version $Id$ * */ public interface AuditableAccessControlEntry extends AccessControlEntry { diff --git a/acl/src/main/java/org/springframework/security/acls/model/AuditableAcl.java b/acl/src/main/java/org/springframework/security/acls/model/AuditableAcl.java index 09904169cf..c256278c12 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/AuditableAcl.java +++ b/acl/src/main/java/org/springframework/security/acls/model/AuditableAcl.java @@ -19,7 +19,6 @@ package org.springframework.security.acls.model; * A mutable ACL that provides audit capabilities. * * @author Ben Alex - * @version $Id$ * */ public interface AuditableAcl extends MutableAcl { diff --git a/acl/src/main/java/org/springframework/security/acls/model/ChildrenExistException.java b/acl/src/main/java/org/springframework/security/acls/model/ChildrenExistException.java index c169787ece..2b05c53c47 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/ChildrenExistException.java +++ b/acl/src/main/java/org/springframework/security/acls/model/ChildrenExistException.java @@ -19,7 +19,6 @@ package org.springframework.security.acls.model; * Thrown if an {@link Acl} cannot be deleted because children Acls exist. * * @author Ben Alex - * @version $Id$ */ public class ChildrenExistException extends AclDataAccessException { //~ Constructors =================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/model/MutableAcl.java b/acl/src/main/java/org/springframework/security/acls/model/MutableAcl.java index d49026ff59..5fdf98ae92 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/MutableAcl.java +++ b/acl/src/main/java/org/springframework/security/acls/model/MutableAcl.java @@ -25,7 +25,6 @@ import java.io.Serializable; * before allowing access to its methods. * * @author Ben Alex - * @version $Id$ */ public interface MutableAcl extends Acl { //~ Methods ======================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/model/MutableAclService.java b/acl/src/main/java/org/springframework/security/acls/model/MutableAclService.java index a1fc7e1082..323979814d 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/MutableAclService.java +++ b/acl/src/main/java/org/springframework/security/acls/model/MutableAclService.java @@ -20,7 +20,6 @@ package org.springframework.security.acls.model; * Provides support for creating and storing Acl instances. * * @author Ben Alex - * @version $Id$ */ public interface MutableAclService extends AclService { //~ Methods ======================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/model/NotFoundException.java b/acl/src/main/java/org/springframework/security/acls/model/NotFoundException.java index ff7fb9aba5..a2f3323698 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/NotFoundException.java +++ b/acl/src/main/java/org/springframework/security/acls/model/NotFoundException.java @@ -19,7 +19,6 @@ package org.springframework.security.acls.model; * Thrown if an ACL-related object cannot be found. * * @author Ben Alex - * @version $Id$ */ public class NotFoundException extends AclDataAccessException { //~ Constructors =================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/model/ObjectIdentity.java b/acl/src/main/java/org/springframework/security/acls/model/ObjectIdentity.java index 688e52757d..97003b11a5 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/ObjectIdentity.java +++ b/acl/src/main/java/org/springframework/security/acls/model/ObjectIdentity.java @@ -30,7 +30,6 @@ import java.io.Serializable; *

* * @author Ben Alex - * @version $Id$ */ public interface ObjectIdentity extends Serializable { //~ Methods ======================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/model/ObjectIdentityGenerator.java b/acl/src/main/java/org/springframework/security/acls/model/ObjectIdentityGenerator.java index e9495ced95..2b8130ad31 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/ObjectIdentityGenerator.java +++ b/acl/src/main/java/org/springframework/security/acls/model/ObjectIdentityGenerator.java @@ -11,7 +11,6 @@ import java.io.Serializable; * instance isn't available. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface ObjectIdentityGenerator { diff --git a/acl/src/main/java/org/springframework/security/acls/model/ObjectIdentityRetrievalStrategy.java b/acl/src/main/java/org/springframework/security/acls/model/ObjectIdentityRetrievalStrategy.java index 3a01d66ff4..3e2e7353a6 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/ObjectIdentityRetrievalStrategy.java +++ b/acl/src/main/java/org/springframework/security/acls/model/ObjectIdentityRetrievalStrategy.java @@ -21,7 +21,6 @@ package org.springframework.security.acls.model; * will be returned for a particular domain object * * @author Ben Alex - * @version $Id$ * */ public interface ObjectIdentityRetrievalStrategy { diff --git a/acl/src/main/java/org/springframework/security/acls/model/OwnershipAcl.java b/acl/src/main/java/org/springframework/security/acls/model/OwnershipAcl.java index 812852c1f3..a0953c18db 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/OwnershipAcl.java +++ b/acl/src/main/java/org/springframework/security/acls/model/OwnershipAcl.java @@ -24,7 +24,6 @@ package org.springframework.security.acls.model; * well as assign a new owner. * * @author Ben Alex - * @version $Id$ */ public interface OwnershipAcl extends MutableAcl { //~ Methods ======================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/model/Permission.java b/acl/src/main/java/org/springframework/security/acls/model/Permission.java index 9ed05a4f1b..15426b43c1 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/Permission.java +++ b/acl/src/main/java/org/springframework/security/acls/model/Permission.java @@ -20,7 +20,6 @@ import java.io.Serializable; * Represents a permission granted to a Sid for a given domain object. * * @author Ben Alex - * @version $Id$ */ public interface Permission extends Serializable { //~ Static fields/initializers ===================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/model/Sid.java b/acl/src/main/java/org/springframework/security/acls/model/Sid.java index 9636cb1b63..2fb0633235 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/Sid.java +++ b/acl/src/main/java/org/springframework/security/acls/model/Sid.java @@ -29,7 +29,6 @@ import java.io.Serializable; *

* * @author Ben Alex - * @version $Id$ */ public interface Sid extends Serializable { //~ Methods ======================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/model/SidRetrievalStrategy.java b/acl/src/main/java/org/springframework/security/acls/model/SidRetrievalStrategy.java index 3b5b365c81..310935cbb0 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/SidRetrievalStrategy.java +++ b/acl/src/main/java/org/springframework/security/acls/model/SidRetrievalStrategy.java @@ -25,7 +25,6 @@ import org.springframework.security.core.Authentication; * for an {@link Authentication}. * * @author Ben Alex - * @version $Id$ */ public interface SidRetrievalStrategy { //~ Methods ======================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/model/UnloadedSidException.java b/acl/src/main/java/org/springframework/security/acls/model/UnloadedSidException.java index 7b05057167..6e49ad962c 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/UnloadedSidException.java +++ b/acl/src/main/java/org/springframework/security/acls/model/UnloadedSidException.java @@ -20,7 +20,6 @@ package org.springframework.security.acls.model; * the caller has requested details for an unloaded Sid. * * @author Ben Alex - * @version $Id$ */ public class UnloadedSidException extends AclDataAccessException { //~ Constructors =================================================================================================== diff --git a/acl/src/main/java/org/springframework/security/acls/model/package.html b/acl/src/main/java/org/springframework/security/acls/model/package.html index e738e3cb94..612305b745 100644 --- a/acl/src/main/java/org/springframework/security/acls/model/package.html +++ b/acl/src/main/java/org/springframework/security/acls/model/package.html @@ -1,5 +1,5 @@ - - -Interfaces and shared classes to manage access control lists (ACLs) for domain object instances. - - + + +Interfaces and shared classes to manage access control lists (ACLs) for domain object instances. + + diff --git a/acl/src/main/resources/createAclSchema.sql b/acl/src/main/resources/createAclSchema.sql index 1bb65cd0cb..e999a9ff22 100644 --- a/acl/src/main/resources/createAclSchema.sql +++ b/acl/src/main/resources/createAclSchema.sql @@ -1,46 +1,46 @@ --- ACL schema sql used in HSQLDB - --- drop table acl_entry; --- drop table acl_object_identity; --- drop table acl_class; --- drop table acl_sid; - - -create table acl_sid( - id bigint generated by default as identity(start with 100) not null primary key, - principal boolean not null, - sid varchar_ignorecase(100) not null, - constraint unique_uk_1 unique(sid,principal)); - -create table acl_class( - id bigint generated by default as identity(start with 100) not null primary key, - class varchar_ignorecase(100) not null, - constraint unique_uk_2 unique(class) -); - -create table acl_object_identity( - id bigint generated by default as identity(start with 100) not null primary key, - object_id_class bigint not null, - object_id_identity bigint not null, - parent_object bigint, - owner_sid bigint, - entries_inheriting boolean not null, - constraint unique_uk_3 unique(object_id_class,object_id_identity), - constraint foreign_fk_1 foreign key(parent_object)references acl_object_identity(id), - constraint foreign_fk_2 foreign key(object_id_class)references acl_class(id), - constraint foreign_fk_3 foreign key(owner_sid)references acl_sid(id) -); - -create table acl_entry( - id bigint generated by default as identity(start with 100) not null primary key, - acl_object_identity bigint not null, - ace_order int not null, - sid bigint not null, - mask integer not null, - granting boolean not null, - audit_success boolean not null, - audit_failure boolean not null, - constraint unique_uk_4 unique(acl_object_identity,ace_order), - constraint foreign_fk_4 foreign key(acl_object_identity) references acl_object_identity(id), - constraint foreign_fk_5 foreign key(sid) references acl_sid(id) -); +-- ACL schema sql used in HSQLDB + +-- drop table acl_entry; +-- drop table acl_object_identity; +-- drop table acl_class; +-- drop table acl_sid; + + +create table acl_sid( + id bigint generated by default as identity(start with 100) not null primary key, + principal boolean not null, + sid varchar_ignorecase(100) not null, + constraint unique_uk_1 unique(sid,principal)); + +create table acl_class( + id bigint generated by default as identity(start with 100) not null primary key, + class varchar_ignorecase(100) not null, + constraint unique_uk_2 unique(class) +); + +create table acl_object_identity( + id bigint generated by default as identity(start with 100) not null primary key, + object_id_class bigint not null, + object_id_identity bigint not null, + parent_object bigint, + owner_sid bigint, + entries_inheriting boolean not null, + constraint unique_uk_3 unique(object_id_class,object_id_identity), + constraint foreign_fk_1 foreign key(parent_object)references acl_object_identity(id), + constraint foreign_fk_2 foreign key(object_id_class)references acl_class(id), + constraint foreign_fk_3 foreign key(owner_sid)references acl_sid(id) +); + +create table acl_entry( + id bigint generated by default as identity(start with 100) not null primary key, + acl_object_identity bigint not null, + ace_order int not null, + sid bigint not null, + mask integer not null, + granting boolean not null, + audit_success boolean not null, + audit_failure boolean not null, + constraint unique_uk_4 unique(acl_object_identity,ace_order), + constraint foreign_fk_4 foreign key(acl_object_identity) references acl_object_identity(id), + constraint foreign_fk_5 foreign key(sid) references acl_sid(id) +); diff --git a/acl/src/main/resources/createAclSchemaPostgres.sql b/acl/src/main/resources/createAclSchemaPostgres.sql index ca07680065..364ebf92d2 100644 --- a/acl/src/main/resources/createAclSchemaPostgres.sql +++ b/acl/src/main/resources/createAclSchemaPostgres.sql @@ -1,46 +1,46 @@ --- ACL Schema SQL for PostgreSQL - --- drop table acl_entry; --- drop table acl_object_identity; --- drop table acl_class; --- drop table acl_sid; - -create table acl_sid( - id bigserial not null primary key, - principal boolean not null, - sid varchar(100) not null, - constraint unique_uk_1 unique(sid,principal) -); - -create table acl_class( - id bigserial not null primary key, - class varchar(100) not null, - constraint unique_uk_2 unique(class) -); - -create table acl_object_identity( - id bigserial primary key, - object_id_class bigint not null, - object_id_identity bigint not null, - parent_object bigint, - owner_sid bigint, - entries_inheriting boolean not null, - constraint unique_uk_3 unique(object_id_class,object_id_identity), - constraint foreign_fk_1 foreign key(parent_object)references acl_object_identity(id), - constraint foreign_fk_2 foreign key(object_id_class)references acl_class(id), - constraint foreign_fk_3 foreign key(owner_sid)references acl_sid(id) -); - -create table acl_entry( - id bigserial primary key, - acl_object_identity bigint not null, - ace_order int not null, - sid bigint not null, - mask integer not null, - granting boolean not null, - audit_success boolean not null, - audit_failure boolean not null, - constraint unique_uk_4 unique(acl_object_identity,ace_order), - constraint foreign_fk_4 foreign key(acl_object_identity) references acl_object_identity(id), - constraint foreign_fk_5 foreign key(sid) references acl_sid(id) -); +-- ACL Schema SQL for PostgreSQL + +-- drop table acl_entry; +-- drop table acl_object_identity; +-- drop table acl_class; +-- drop table acl_sid; + +create table acl_sid( + id bigserial not null primary key, + principal boolean not null, + sid varchar(100) not null, + constraint unique_uk_1 unique(sid,principal) +); + +create table acl_class( + id bigserial not null primary key, + class varchar(100) not null, + constraint unique_uk_2 unique(class) +); + +create table acl_object_identity( + id bigserial primary key, + object_id_class bigint not null, + object_id_identity bigint not null, + parent_object bigint, + owner_sid bigint, + entries_inheriting boolean not null, + constraint unique_uk_3 unique(object_id_class,object_id_identity), + constraint foreign_fk_1 foreign key(parent_object)references acl_object_identity(id), + constraint foreign_fk_2 foreign key(object_id_class)references acl_class(id), + constraint foreign_fk_3 foreign key(owner_sid)references acl_sid(id) +); + +create table acl_entry( + id bigserial primary key, + acl_object_identity bigint not null, + ace_order int not null, + sid bigint not null, + mask integer not null, + granting boolean not null, + audit_success boolean not null, + audit_failure boolean not null, + constraint unique_uk_4 unique(acl_object_identity,ace_order), + constraint foreign_fk_4 foreign key(acl_object_identity) references acl_object_identity(id), + constraint foreign_fk_5 foreign key(sid) references acl_sid(id) +); diff --git a/acl/src/main/resources/select.sql b/acl/src/main/resources/select.sql index 4e9486c83c..ad759c7c7c 100644 --- a/acl/src/main/resources/select.sql +++ b/acl/src/main/resources/select.sql @@ -1,39 +1,39 @@ --- Not required. Just shows the sort of queries being sent to DB. - - -select acl_object_identity.object_id_identity, - acl_entry.ace_order, - acl_object_identity.id as acl_id, - acl_object_identity.parent_object, - acl_object_identity, - entries_inheriting, - acl_entry.id as ace_id, - acl_entry.mask, - acl_entry.granting, - acl_entry.audit_success, - acl_entry.audit_failure, - acl_sid.principal as ace_principal, - acl_sid.sid as ace_sid, - acli_sid.principal as acl_principal, - acli_sid.sid as acl_sid, - acl_class.class - -from acl_object_identity, - acl_sid acli_sid, - acl_class - -left join acl_entry on acl_object_identity.id = acl_entry.acl_object_identity -left join acl_sid on acl_entry.sid = acl_sid.id - -where - acli_sid.id = acl_object_identity.owner_sid - -and acl_class.id = acl_object_identity.object_id_class - -and ( - - (acl_object_identity.object_id_identity = 1 and acl_class.class = 'sample.contact.contact') -or - (acl_object_identity.object_id_identity = 2000 and acl_class.class = 'sample.contact.contact') - -) order by acl_object_identity.object_id_identity asc, acl_entry.ace_order asc +-- Not required. Just shows the sort of queries being sent to DB. + + +select acl_object_identity.object_id_identity, + acl_entry.ace_order, + acl_object_identity.id as acl_id, + acl_object_identity.parent_object, + acl_object_identity, + entries_inheriting, + acl_entry.id as ace_id, + acl_entry.mask, + acl_entry.granting, + acl_entry.audit_success, + acl_entry.audit_failure, + acl_sid.principal as ace_principal, + acl_sid.sid as ace_sid, + acli_sid.principal as acl_principal, + acli_sid.sid as acl_sid, + acl_class.class + +from acl_object_identity, + acl_sid acli_sid, + acl_class + +left join acl_entry on acl_object_identity.id = acl_entry.acl_object_identity +left join acl_sid on acl_entry.sid = acl_sid.id + +where + acli_sid.id = acl_object_identity.owner_sid + +and acl_class.id = acl_object_identity.object_id_class + +and ( + + (acl_object_identity.object_id_identity = 1 and acl_class.class = 'sample.contact.contact') +or + (acl_object_identity.object_id_identity = 2000 and acl_class.class = 'sample.contact.contact') + +) order by acl_object_identity.object_id_identity asc, acl_entry.ace_order asc diff --git a/acl/src/test/java/org/springframework/security/acls/AclFormattingUtilsTests.java b/acl/src/test/java/org/springframework/security/acls/AclFormattingUtilsTests.java index bd1325cf5a..a1adee6522 100644 --- a/acl/src/test/java/org/springframework/security/acls/AclFormattingUtilsTests.java +++ b/acl/src/test/java/org/springframework/security/acls/AclFormattingUtilsTests.java @@ -1,127 +1,127 @@ -package org.springframework.security.acls; - -import org.springframework.security.acls.domain.AclFormattingUtils; -import org.springframework.security.acls.model.Permission; - -import junit.framework.Assert; -import junit.framework.TestCase; - -/** - * Tests for {@link AclFormattingUtils}. - * - * @author Andrei Stefan - */ -public class AclFormattingUtilsTests extends TestCase { - - //~ Methods ======================================================================================================== - - public final void testDemergePatternsParametersConstraints() throws Exception { - try { - AclFormattingUtils.demergePatterns(null, "SOME STRING"); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - AclFormattingUtils.demergePatterns("SOME STRING", null); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - AclFormattingUtils.demergePatterns("SOME STRING", "LONGER SOME STRING"); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - AclFormattingUtils.demergePatterns("SOME STRING", "SAME LENGTH"); - Assert.assertTrue(true); - } - catch (IllegalArgumentException notExpected) { - Assert.fail("It shouldn't have thrown IllegalArgumentException"); - } - } - - public final void testDemergePatterns() throws Exception { - String original = "...........................A...R"; - String removeBits = "...............................R"; - Assert.assertEquals("...........................A....", AclFormattingUtils - .demergePatterns(original, removeBits)); - - Assert.assertEquals("ABCDEF", AclFormattingUtils.demergePatterns("ABCDEF", "......")); - Assert.assertEquals("......", AclFormattingUtils.demergePatterns("ABCDEF", "GHIJKL")); - } - - public final void testMergePatternsParametersConstraints() throws Exception { - try { - AclFormattingUtils.mergePatterns(null, "SOME STRING"); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - AclFormattingUtils.mergePatterns("SOME STRING", null); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - AclFormattingUtils.mergePatterns("SOME STRING", "LONGER SOME STRING"); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - AclFormattingUtils.mergePatterns("SOME STRING", "SAME LENGTH"); - Assert.assertTrue(true); - } - catch (IllegalArgumentException notExpected) { - Assert.fail("It shouldn't have thrown IllegalArgumentException"); - } - } - - public final void testMergePatterns() throws Exception { - String original = "...............................R"; - String extraBits = "...........................A...."; - Assert.assertEquals("...........................A...R", AclFormattingUtils - .mergePatterns(original, extraBits)); - - Assert.assertEquals("ABCDEF", AclFormattingUtils.mergePatterns("ABCDEF", "......")); - Assert.assertEquals("GHIJKL", AclFormattingUtils.mergePatterns("ABCDEF", "GHIJKL")); - } - - public final void testBinaryPrints() throws Exception { - Assert.assertEquals("............................****", AclFormattingUtils.printBinary(15)); - - try { - AclFormattingUtils.printBinary(15, Permission.RESERVED_ON); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException notExpected) { - Assert.assertTrue(true); - } - - try { - AclFormattingUtils.printBinary(15, Permission.RESERVED_OFF); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException notExpected) { - Assert.assertTrue(true); - } - - Assert.assertEquals("............................xxxx", AclFormattingUtils.printBinary(15, 'x')); - } -} +package org.springframework.security.acls; + +import org.springframework.security.acls.domain.AclFormattingUtils; +import org.springframework.security.acls.model.Permission; + +import junit.framework.Assert; +import junit.framework.TestCase; + +/** + * Tests for {@link AclFormattingUtils}. + * + * @author Andrei Stefan + */ +public class AclFormattingUtilsTests extends TestCase { + + //~ Methods ======================================================================================================== + + public final void testDemergePatternsParametersConstraints() throws Exception { + try { + AclFormattingUtils.demergePatterns(null, "SOME STRING"); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + AclFormattingUtils.demergePatterns("SOME STRING", null); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + AclFormattingUtils.demergePatterns("SOME STRING", "LONGER SOME STRING"); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + AclFormattingUtils.demergePatterns("SOME STRING", "SAME LENGTH"); + Assert.assertTrue(true); + } + catch (IllegalArgumentException notExpected) { + Assert.fail("It shouldn't have thrown IllegalArgumentException"); + } + } + + public final void testDemergePatterns() throws Exception { + String original = "...........................A...R"; + String removeBits = "...............................R"; + Assert.assertEquals("...........................A....", AclFormattingUtils + .demergePatterns(original, removeBits)); + + Assert.assertEquals("ABCDEF", AclFormattingUtils.demergePatterns("ABCDEF", "......")); + Assert.assertEquals("......", AclFormattingUtils.demergePatterns("ABCDEF", "GHIJKL")); + } + + public final void testMergePatternsParametersConstraints() throws Exception { + try { + AclFormattingUtils.mergePatterns(null, "SOME STRING"); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + AclFormattingUtils.mergePatterns("SOME STRING", null); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + AclFormattingUtils.mergePatterns("SOME STRING", "LONGER SOME STRING"); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + AclFormattingUtils.mergePatterns("SOME STRING", "SAME LENGTH"); + Assert.assertTrue(true); + } + catch (IllegalArgumentException notExpected) { + Assert.fail("It shouldn't have thrown IllegalArgumentException"); + } + } + + public final void testMergePatterns() throws Exception { + String original = "...............................R"; + String extraBits = "...........................A...."; + Assert.assertEquals("...........................A...R", AclFormattingUtils + .mergePatterns(original, extraBits)); + + Assert.assertEquals("ABCDEF", AclFormattingUtils.mergePatterns("ABCDEF", "......")); + Assert.assertEquals("GHIJKL", AclFormattingUtils.mergePatterns("ABCDEF", "GHIJKL")); + } + + public final void testBinaryPrints() throws Exception { + Assert.assertEquals("............................****", AclFormattingUtils.printBinary(15)); + + try { + AclFormattingUtils.printBinary(15, Permission.RESERVED_ON); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException notExpected) { + Assert.assertTrue(true); + } + + try { + AclFormattingUtils.printBinary(15, Permission.RESERVED_OFF); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException notExpected) { + Assert.assertTrue(true); + } + + Assert.assertEquals("............................xxxx", AclFormattingUtils.printBinary(15, 'x')); + } +} diff --git a/acl/src/test/java/org/springframework/security/acls/AclPermissionEvaluatorTests.java b/acl/src/test/java/org/springframework/security/acls/AclPermissionEvaluatorTests.java index 32c1420c4e..d07db14622 100644 --- a/acl/src/test/java/org/springframework/security/acls/AclPermissionEvaluatorTests.java +++ b/acl/src/test/java/org/springframework/security/acls/AclPermissionEvaluatorTests.java @@ -15,7 +15,6 @@ import org.springframework.security.core.Authentication; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class AclPermissionEvaluatorTests { diff --git a/acl/src/test/java/org/springframework/security/acls/TargetObject.java b/acl/src/test/java/org/springframework/security/acls/TargetObject.java index b51f5aa11c..e9738e40f8 100644 --- a/acl/src/test/java/org/springframework/security/acls/TargetObject.java +++ b/acl/src/test/java/org/springframework/security/acls/TargetObject.java @@ -4,7 +4,6 @@ package org.springframework.security.acls; * Dummy domain object class * * @author Luke Taylor - * @version $Id$ */ public final class TargetObject { diff --git a/acl/src/test/java/org/springframework/security/acls/domain/AccessControlImplEntryTests.java b/acl/src/test/java/org/springframework/security/acls/domain/AccessControlImplEntryTests.java index 19bfb928f0..db782d3bec 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/AccessControlImplEntryTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/AccessControlImplEntryTests.java @@ -1,105 +1,104 @@ -package org.springframework.security.acls.domain; - -import static org.junit.Assert.*; - -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.jmock.integration.junit4.JUnit4Mockery; -import org.junit.Test; -import org.springframework.security.acls.model.AccessControlEntry; -import org.springframework.security.acls.model.Acl; -import org.springframework.security.acls.model.AuditableAccessControlEntry; -import org.springframework.security.acls.model.ObjectIdentity; -import org.springframework.security.acls.model.Sid; - -/** - * Tests for {@link AccessControlEntryImpl}. - * - * @author Andrei Stefan - * @version $Id$ - */ -public class AccessControlImplEntryTests { - Mockery jmock = new JUnit4Mockery(); - - //~ Methods ======================================================================================================== - - @Test - public void testConstructorRequiredFields() { - // Check Acl field is present - try { - new AccessControlEntryImpl(null, null, new PrincipalSid("johndoe"), - BasePermission.ADMINISTRATION, true, true, true); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - - // Check Sid field is present - try { - new AccessControlEntryImpl(null, jmock.mock(Acl.class), null, - BasePermission.ADMINISTRATION, true, true, true); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - - // Check Permission field is present - try { - new AccessControlEntryImpl(null, jmock.mock(Acl.class), new PrincipalSid("johndoe"), null, - true, true, true); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - } - - @Test - public void testAccessControlEntryImplGetters() { - Acl mockAcl = jmock.mock(Acl.class); - Sid sid = new PrincipalSid("johndoe"); - - // Create a sample entry - AccessControlEntry ace = new AccessControlEntryImpl(new Long(1), mockAcl, sid, BasePermission.ADMINISTRATION, - true, true, true); - - // and check every get() method - assertEquals(new Long(1), ace.getId()); - assertEquals(mockAcl, ace.getAcl()); - assertEquals(sid, ace.getSid()); - assertTrue(ace.isGranting()); - assertEquals(BasePermission.ADMINISTRATION, ace.getPermission()); - assertTrue(((AuditableAccessControlEntry) ace).isAuditFailure()); - assertTrue(((AuditableAccessControlEntry) ace).isAuditSuccess()); - } - - @Test - public void testEquals() { - final Acl mockAcl = jmock.mock(Acl.class); - final ObjectIdentity oid = jmock.mock(ObjectIdentity.class); - jmock.checking(new Expectations() {{ - allowing(mockAcl).getObjectIdentity(); will(returnValue(oid)); - }}); - Sid sid = new PrincipalSid("johndoe"); - - AccessControlEntry ace = new AccessControlEntryImpl(new Long(1), mockAcl, sid, BasePermission.ADMINISTRATION, - true, true, true); - - assertFalse(ace.equals(null)); - assertFalse(ace.equals(new Long(100))); - assertTrue(ace.equals(ace)); - assertTrue(ace.equals(new AccessControlEntryImpl(new Long(1), mockAcl, sid, - BasePermission.ADMINISTRATION, true, true, true))); - assertFalse(ace.equals(new AccessControlEntryImpl(new Long(2), mockAcl, sid, - BasePermission.ADMINISTRATION, true, true, true))); - assertFalse(ace.equals(new AccessControlEntryImpl(new Long(1), mockAcl, new PrincipalSid("scott"), - BasePermission.ADMINISTRATION, true, true, true))); - assertFalse(ace.equals(new AccessControlEntryImpl(new Long(1), mockAcl, sid, BasePermission.WRITE, true, - true, true))); - assertFalse(ace.equals(new AccessControlEntryImpl(new Long(1), mockAcl, sid, - BasePermission.ADMINISTRATION, false, true, true))); - assertFalse(ace.equals(new AccessControlEntryImpl(new Long(1), mockAcl, sid, - BasePermission.ADMINISTRATION, true, false, true))); - assertFalse(ace.equals(new AccessControlEntryImpl(new Long(1), mockAcl, sid, - BasePermission.ADMINISTRATION, true, true, false))); - } -} +package org.springframework.security.acls.domain; + +import static org.junit.Assert.*; + +import org.jmock.Expectations; +import org.jmock.Mockery; +import org.jmock.integration.junit4.JUnit4Mockery; +import org.junit.Test; +import org.springframework.security.acls.model.AccessControlEntry; +import org.springframework.security.acls.model.Acl; +import org.springframework.security.acls.model.AuditableAccessControlEntry; +import org.springframework.security.acls.model.ObjectIdentity; +import org.springframework.security.acls.model.Sid; + +/** + * Tests for {@link AccessControlEntryImpl}. + * + * @author Andrei Stefan + */ +public class AccessControlImplEntryTests { + Mockery jmock = new JUnit4Mockery(); + + //~ Methods ======================================================================================================== + + @Test + public void testConstructorRequiredFields() { + // Check Acl field is present + try { + new AccessControlEntryImpl(null, null, new PrincipalSid("johndoe"), + BasePermission.ADMINISTRATION, true, true, true); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + + // Check Sid field is present + try { + new AccessControlEntryImpl(null, jmock.mock(Acl.class), null, + BasePermission.ADMINISTRATION, true, true, true); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + + // Check Permission field is present + try { + new AccessControlEntryImpl(null, jmock.mock(Acl.class), new PrincipalSid("johndoe"), null, + true, true, true); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + } + + @Test + public void testAccessControlEntryImplGetters() { + Acl mockAcl = jmock.mock(Acl.class); + Sid sid = new PrincipalSid("johndoe"); + + // Create a sample entry + AccessControlEntry ace = new AccessControlEntryImpl(new Long(1), mockAcl, sid, BasePermission.ADMINISTRATION, + true, true, true); + + // and check every get() method + assertEquals(new Long(1), ace.getId()); + assertEquals(mockAcl, ace.getAcl()); + assertEquals(sid, ace.getSid()); + assertTrue(ace.isGranting()); + assertEquals(BasePermission.ADMINISTRATION, ace.getPermission()); + assertTrue(((AuditableAccessControlEntry) ace).isAuditFailure()); + assertTrue(((AuditableAccessControlEntry) ace).isAuditSuccess()); + } + + @Test + public void testEquals() { + final Acl mockAcl = jmock.mock(Acl.class); + final ObjectIdentity oid = jmock.mock(ObjectIdentity.class); + jmock.checking(new Expectations() {{ + allowing(mockAcl).getObjectIdentity(); will(returnValue(oid)); + }}); + Sid sid = new PrincipalSid("johndoe"); + + AccessControlEntry ace = new AccessControlEntryImpl(new Long(1), mockAcl, sid, BasePermission.ADMINISTRATION, + true, true, true); + + assertFalse(ace.equals(null)); + assertFalse(ace.equals(new Long(100))); + assertTrue(ace.equals(ace)); + assertTrue(ace.equals(new AccessControlEntryImpl(new Long(1), mockAcl, sid, + BasePermission.ADMINISTRATION, true, true, true))); + assertFalse(ace.equals(new AccessControlEntryImpl(new Long(2), mockAcl, sid, + BasePermission.ADMINISTRATION, true, true, true))); + assertFalse(ace.equals(new AccessControlEntryImpl(new Long(1), mockAcl, new PrincipalSid("scott"), + BasePermission.ADMINISTRATION, true, true, true))); + assertFalse(ace.equals(new AccessControlEntryImpl(new Long(1), mockAcl, sid, BasePermission.WRITE, true, + true, true))); + assertFalse(ace.equals(new AccessControlEntryImpl(new Long(1), mockAcl, sid, + BasePermission.ADMINISTRATION, false, true, true))); + assertFalse(ace.equals(new AccessControlEntryImpl(new Long(1), mockAcl, sid, + BasePermission.ADMINISTRATION, true, false, true))); + assertFalse(ace.equals(new AccessControlEntryImpl(new Long(1), mockAcl, sid, + BasePermission.ADMINISTRATION, true, true, false))); + } +} diff --git a/acl/src/test/java/org/springframework/security/acls/domain/AclImplTests.java b/acl/src/test/java/org/springframework/security/acls/domain/AclImplTests.java index a01b5ad9e0..413b4d5e1c 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/AclImplTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/AclImplTests.java @@ -1,567 +1,567 @@ -package org.springframework.security.acls.domain; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.jmock.Mockery; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.springframework.security.acls.model.AccessControlEntry; -import org.springframework.security.acls.model.Acl; -import org.springframework.security.acls.model.AlreadyExistsException; -import org.springframework.security.acls.model.AuditableAccessControlEntry; -import org.springframework.security.acls.model.AuditableAcl; -import org.springframework.security.acls.model.ChildrenExistException; -import org.springframework.security.acls.model.MutableAcl; -import org.springframework.security.acls.model.MutableAclService; -import org.springframework.security.acls.model.NotFoundException; -import org.springframework.security.acls.model.ObjectIdentity; -import org.springframework.security.acls.model.OwnershipAcl; -import org.springframework.security.acls.model.Permission; -import org.springframework.security.acls.model.Sid; -import org.springframework.security.authentication.TestingAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthorityImpl; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.util.FieldUtils; - - -/** - * Tests for {@link AclImpl}. - * - * @author Andrei Stefan - */ -public class AclImplTests { - private static final String TARGET_CLASS = "org.springframework.security.acls.TargetObject"; - private static final List READ = Arrays.asList(BasePermission.READ ); - private static final List WRITE = Arrays.asList(BasePermission.WRITE); - private static final List CREATE = Arrays.asList(BasePermission.CREATE ); - private static final List DELETE = Arrays.asList(BasePermission.DELETE ); - private static final List SCOTT = Arrays.asList((Sid)new PrincipalSid("scott")); - private static final List BEN = Arrays.asList((Sid)new PrincipalSid("ben")); - - Authentication auth = new TestingAuthenticationToken("joe", "ignored", "ROLE_ADMINISTRATOR"); - Mockery jmockCtx = new Mockery(); - AclAuthorizationStrategy mockAuthzStrategy; - AuditLogger mockAuditLogger; - ObjectIdentity objectIdentity = new ObjectIdentityImpl(TARGET_CLASS, 100); - - // ~ Methods ======================================================================================================== - - @Before - public void setUp() throws Exception { - SecurityContextHolder.getContext().setAuthentication(auth); - mockAuthzStrategy = mock(AclAuthorizationStrategy.class); - mockAuditLogger = mock(AuditLogger.class);; - auth.setAuthenticated(true); - } - - @After - public void tearDown() throws Exception { - SecurityContextHolder.clearContext(); - } - - @Test(expected=IllegalArgumentException.class) - public void constructorsRejectNullObjectIdentity() throws Exception { - try { - new AclImpl(null, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid("joe")); - fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - new AclImpl(null, 1, mockAuthzStrategy, mockAuditLogger); - } - - @Test(expected=IllegalArgumentException.class) - public void constructorsRejectNullId() throws Exception { - try { - new AclImpl(objectIdentity, null, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid("joe")); - fail("Should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - new AclImpl(objectIdentity, null, mockAuthzStrategy, mockAuditLogger); - } - - @Test(expected=IllegalArgumentException.class) - public void constructorsRejectNullAclAuthzStrategy() throws Exception { - try { - new AclImpl(objectIdentity, 1, null, mockAuditLogger, null, null, true, new PrincipalSid("joe")); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - new AclImpl(objectIdentity, 1, null, mockAuditLogger); - } - - @Test(expected=IllegalArgumentException.class) - public void constructorsRejectNullAuditLogger() throws Exception { - try { - new AclImpl(objectIdentity, 1, mockAuthzStrategy, null, null, null, true, new PrincipalSid("joe")); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - new AclImpl(objectIdentity, 1, mockAuthzStrategy, null); - } - - @Test - public void insertAceRejectsNullParameters() throws Exception { - MutableAcl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid( - "joe")); - try { - acl.insertAce(0, null, new GrantedAuthoritySid("ROLE_IGNORED"), true); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - try { - acl.insertAce(0, BasePermission.READ, null, true); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - } - - @Test - public void insertAceAddsElementAtCorrectIndex() throws Exception { - MutableAcl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid("joe")); - MockAclService service = new MockAclService(); - - // Insert one permission - acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST1"), true); - service.updateAcl(acl); - // Check it was successfully added - assertEquals(1, acl.getEntries().size()); - assertEquals(acl.getEntries().get(0).getAcl(), acl); - assertEquals(acl.getEntries().get(0).getPermission(), BasePermission.READ); - assertEquals(acl.getEntries().get(0).getSid(), new GrantedAuthoritySid("ROLE_TEST1")); - - // Add a second permission - acl.insertAce(1, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST2"), true); - service.updateAcl(acl); - // Check it was added on the last position - assertEquals(2, acl.getEntries().size()); - assertEquals(acl.getEntries().get(1).getAcl(), acl); - assertEquals(acl.getEntries().get(1).getPermission(), BasePermission.READ); - assertEquals(acl.getEntries().get(1).getSid(), new GrantedAuthoritySid("ROLE_TEST2")); - - // Add a third permission, after the first one - acl.insertAce(1, BasePermission.WRITE, new GrantedAuthoritySid("ROLE_TEST3"), false); - service.updateAcl(acl); - assertEquals(3, acl.getEntries().size()); - // Check the third entry was added between the two existent ones - assertEquals(acl.getEntries().get(0).getPermission(), BasePermission.READ); - assertEquals(acl.getEntries().get(0).getSid(), new GrantedAuthoritySid("ROLE_TEST1")); - assertEquals(acl.getEntries().get(1).getPermission(), BasePermission.WRITE); - assertEquals(acl.getEntries().get(1).getSid(), new GrantedAuthoritySid("ROLE_TEST3")); - assertEquals(acl.getEntries().get(2).getPermission(), BasePermission.READ); - assertEquals(acl.getEntries().get(2).getSid(), new GrantedAuthoritySid("ROLE_TEST2")); - } - - @Test(expected=NotFoundException.class) - public void insertAceFailsForNonExistentElement() throws Exception { - MutableAcl acl = new AclImpl(objectIdentity,1, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid( - "joe")); - MockAclService service = new MockAclService(); - - // Insert one permission - acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST1"), true); - service.updateAcl(acl); - - acl.insertAce(55, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST2"), true); - } - - @Test - public void deleteAceKeepsInitialOrdering() throws Exception { - MutableAcl acl = new AclImpl(objectIdentity,1, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid( - "joe")); - MockAclService service = new MockAclService(); - - // Add several permissions - acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST1"), true); - acl.insertAce(1, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST2"), true); - acl.insertAce(2, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST3"), true); - service.updateAcl(acl); - - // Delete first permission and check the order of the remaining permissions is kept - acl.deleteAce(0); - assertEquals(2, acl.getEntries().size()); - assertEquals(acl.getEntries().get(0).getSid(), new GrantedAuthoritySid("ROLE_TEST2")); - assertEquals(acl.getEntries().get(1).getSid(), new GrantedAuthoritySid("ROLE_TEST3")); - - // Add one more permission and remove the permission in the middle - acl.insertAce(2, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST4"), true); - service.updateAcl(acl); - acl.deleteAce(1); - assertEquals(2, acl.getEntries().size()); - assertEquals(acl.getEntries().get(0).getSid(), new GrantedAuthoritySid("ROLE_TEST2")); - assertEquals(acl.getEntries().get(1).getSid(), new GrantedAuthoritySid("ROLE_TEST4")); - - // Remove remaining permissions - acl.deleteAce(1); - acl.deleteAce(0); - assertEquals(0, acl.getEntries().size()); - } - - @Test - public void deleteAceFailsForNonExistentElement() throws Exception { - AclAuthorizationStrategyImpl strategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), - new GrantedAuthorityImpl("ROLE_GENERAL") }); - AuditLogger auditLogger = new ConsoleAuditLogger(); - MutableAcl acl = new AclImpl(objectIdentity, (1), strategy, auditLogger, null, null, true, new PrincipalSid( - "joe")); - try { - acl.deleteAce(99); - fail("It should have thrown NotFoundException"); - } - catch (NotFoundException expected) { - } - } - - @Test - public void isGrantingRejectsEmptyParameters() throws Exception { - MutableAcl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid( - "joe")); - Sid ben = new PrincipalSid("ben"); - try { - acl.isGranted(new ArrayList(0), Arrays.asList(ben) , false); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - try { - acl.isGranted(READ, new ArrayList(0), false); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - } - - @Test - public void isGrantingGrantsAccessForAclWithNoParent() throws Exception { - Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_GENERAL","ROLE_GUEST"); - auth.setAuthenticated(true); - SecurityContextHolder.getContext().setAuthentication(auth); - ObjectIdentity rootOid = new ObjectIdentityImpl(TARGET_CLASS, 100); - - // Create an ACL which owner is not the authenticated principal - MutableAcl rootAcl = new AclImpl(rootOid, 1, mockAuthzStrategy, mockAuditLogger, null, null, false, new PrincipalSid( - "joe")); - - // Grant some permissions - rootAcl.insertAce(0, BasePermission.READ, new PrincipalSid("ben"), false); - rootAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid("scott"), true); - rootAcl.insertAce(2, BasePermission.WRITE, new PrincipalSid("rod"), false); - rootAcl.insertAce(3, BasePermission.WRITE, new GrantedAuthoritySid("WRITE_ACCESS_ROLE"), true); - - // Check permissions granting - List permissions = Arrays.asList(BasePermission.READ, BasePermission.CREATE); - List sids = Arrays.asList(new PrincipalSid("ben"), new GrantedAuthoritySid("ROLE_GUEST")); - assertFalse(rootAcl.isGranted(permissions, sids, false)); - try { - rootAcl.isGranted(permissions, SCOTT, false); - fail("It should have thrown NotFoundException"); - } - catch (NotFoundException expected) { - } - assertTrue(rootAcl.isGranted(WRITE, SCOTT, false)); - assertFalse(rootAcl.isGranted(WRITE, - Arrays.asList(new PrincipalSid("rod"), new GrantedAuthoritySid("WRITE_ACCESS_ROLE")), false)); - assertTrue(rootAcl.isGranted(WRITE, Arrays.asList(new GrantedAuthoritySid("WRITE_ACCESS_ROLE"), new PrincipalSid("rod")), false)); - try { - // Change the type of the Sid and check the granting process - rootAcl.isGranted(WRITE, Arrays.asList(new GrantedAuthoritySid("rod"), new PrincipalSid("WRITE_ACCESS_ROLE")), false); - fail("It should have thrown NotFoundException"); - } - catch (NotFoundException expected) { - } - } - - @Test - public void isGrantingGrantsAccessForInheritableAcls() throws Exception { - Authentication auth = new TestingAuthenticationToken("ben", "ignored","ROLE_GENERAL"); - auth.setAuthenticated(true); - SecurityContextHolder.getContext().setAuthentication(auth); - ObjectIdentity grandParentOid = new ObjectIdentityImpl(TARGET_CLASS, 100); - ObjectIdentity parentOid1 = new ObjectIdentityImpl(TARGET_CLASS, 101); - ObjectIdentity parentOid2 = new ObjectIdentityImpl(TARGET_CLASS, 102); - ObjectIdentity childOid1 = new ObjectIdentityImpl(TARGET_CLASS, 103); - ObjectIdentity childOid2 = new ObjectIdentityImpl(TARGET_CLASS, 104); - - // Create ACLs - MutableAcl grandParentAcl = new AclImpl(grandParentOid, 1, mockAuthzStrategy, mockAuditLogger, null, null, false, - new PrincipalSid("joe")); - MutableAcl parentAcl1 = new AclImpl(parentOid1, 2, mockAuthzStrategy, mockAuditLogger, null, null, true, - new PrincipalSid("joe")); - MutableAcl parentAcl2 = new AclImpl(parentOid2, 3, mockAuthzStrategy, mockAuditLogger, null, null, true, - new PrincipalSid("joe")); - MutableAcl childAcl1 = new AclImpl(childOid1, 4, mockAuthzStrategy, mockAuditLogger, null, null, true, - new PrincipalSid("joe")); - MutableAcl childAcl2 = new AclImpl(childOid2, 4, mockAuthzStrategy, mockAuditLogger, null, null, false, - new PrincipalSid("joe")); - - // Create hierarchies - childAcl2.setParent(childAcl1); - childAcl1.setParent(parentAcl1); - parentAcl2.setParent(grandParentAcl); - parentAcl1.setParent(grandParentAcl); - - // Add some permissions - grandParentAcl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_USER_READ"), true); - grandParentAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid("ben"), true); - grandParentAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid("ben"), false); - grandParentAcl.insertAce(3, BasePermission.DELETE, new PrincipalSid("scott"), true); - parentAcl1.insertAce(0, BasePermission.READ, new PrincipalSid("scott"), true); - parentAcl1.insertAce(1, BasePermission.DELETE, new PrincipalSid("scott"), false); - parentAcl2.insertAce(0, BasePermission.CREATE, new PrincipalSid("ben"), true); - childAcl1.insertAce(0, BasePermission.CREATE, new PrincipalSid("scott"), true); - - // Check granting process for parent1 - assertTrue(parentAcl1.isGranted(READ, SCOTT, false)); - assertTrue(parentAcl1.isGranted(READ, Arrays.asList((Sid)new GrantedAuthoritySid("ROLE_USER_READ")), false)); - assertTrue(parentAcl1.isGranted(WRITE, BEN, false)); - assertFalse(parentAcl1.isGranted(DELETE, BEN, false)); - assertFalse(parentAcl1.isGranted(DELETE, SCOTT, false)); - - // Check granting process for parent2 - assertTrue(parentAcl2.isGranted(CREATE, BEN, false)); - assertTrue(parentAcl2.isGranted(WRITE, BEN, false)); - assertFalse(parentAcl2.isGranted(DELETE, BEN, false)); - - // Check granting process for child1 - assertTrue(childAcl1.isGranted(CREATE, SCOTT, - false)); - assertTrue(childAcl1.isGranted(READ, Arrays.asList((Sid)new GrantedAuthoritySid("ROLE_USER_READ")), false)); - assertFalse(childAcl1.isGranted(DELETE, BEN, false)); - - // Check granting process for child2 (doesn't inherit the permissions from its parent) - try { - assertTrue(childAcl2.isGranted(CREATE, SCOTT, false)); - fail("It should have thrown NotFoundException"); - } - catch (NotFoundException expected) { - assertTrue(true); - } - try { - assertTrue(childAcl2.isGranted(CREATE, Arrays.asList((Sid)new PrincipalSid("joe")), false)); - fail("It should have thrown NotFoundException"); - } - catch (NotFoundException expected) { - assertTrue(true); - } - } - - @Test - public void updatedAceValuesAreCorrectlyReflectedInAcl() throws Exception { - Authentication auth = new TestingAuthenticationToken("ben", "ignored","ROLE_GENERAL"); - auth.setAuthenticated(true); - SecurityContextHolder.getContext().setAuthentication(auth); - MutableAcl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, false, new PrincipalSid( - "joe")); - MockAclService service = new MockAclService(); - - acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_USER_READ"), true); - acl.insertAce(1, BasePermission.WRITE, new GrantedAuthoritySid("ROLE_USER_READ"), true); - acl.insertAce(2, BasePermission.CREATE, new PrincipalSid("ben"), true); - service.updateAcl(acl); - - assertEquals(acl.getEntries().get(0).getPermission(), BasePermission.READ); - assertEquals(acl.getEntries().get(1).getPermission(), BasePermission.WRITE); - assertEquals(acl.getEntries().get(2).getPermission(), BasePermission.CREATE); - - // Change each permission - acl.updateAce(0, BasePermission.CREATE); - acl.updateAce(1, BasePermission.DELETE); - acl.updateAce(2, BasePermission.READ); - - // Check the change was successfuly made - assertEquals(acl.getEntries().get(0).getPermission(), BasePermission.CREATE); - assertEquals(acl.getEntries().get(1).getPermission(), BasePermission.DELETE); - assertEquals(acl.getEntries().get(2).getPermission(), BasePermission.READ); - } - - @Test - public void auditableEntryFlagsAreUpdatedCorrectly() throws Exception { - Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_AUDITING", "ROLE_GENERAL"); - auth.setAuthenticated(true); - SecurityContextHolder.getContext().setAuthentication(auth); - MutableAcl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, false, new PrincipalSid( - "joe")); - MockAclService service = new MockAclService(); - - acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_USER_READ"), true); - acl.insertAce(1, BasePermission.WRITE, new GrantedAuthoritySid("ROLE_USER_READ"), true); - service.updateAcl(acl); - - assertFalse(((AuditableAccessControlEntry) acl.getEntries().get(0)).isAuditFailure()); - assertFalse(((AuditableAccessControlEntry) acl.getEntries().get(1)).isAuditFailure()); - assertFalse(((AuditableAccessControlEntry) acl.getEntries().get(0)).isAuditSuccess()); - assertFalse(((AuditableAccessControlEntry) acl.getEntries().get(1)).isAuditSuccess()); - - // Change each permission - ((AuditableAcl) acl).updateAuditing(0, true, true); - ((AuditableAcl) acl).updateAuditing(1, true, true); - - // Check the change was successfuly made - assertTrue(((AuditableAccessControlEntry) acl.getEntries().get(0)).isAuditFailure()); - assertTrue(((AuditableAccessControlEntry) acl.getEntries().get(1)).isAuditFailure()); - assertTrue(((AuditableAccessControlEntry) acl.getEntries().get(0)).isAuditSuccess()); - assertTrue(((AuditableAccessControlEntry) acl.getEntries().get(1)).isAuditSuccess()); - } - - @Test - public void gettersAndSettersAreConsistent() throws Exception { - Authentication auth = new TestingAuthenticationToken("ben", "ignored", new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_GENERAL") }); - auth.setAuthenticated(true); - SecurityContextHolder.getContext().setAuthentication(auth); - ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, (100)); - ObjectIdentity identity2 = new ObjectIdentityImpl(TARGET_CLASS, (101)); - MutableAcl acl = new AclImpl(identity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, - new PrincipalSid("joe")); - MutableAcl parentAcl = new AclImpl(identity2, 2, mockAuthzStrategy, mockAuditLogger, null, null, true, - new PrincipalSid("joe")); - MockAclService service = new MockAclService(); - acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_USER_READ"), true); - acl.insertAce(1, BasePermission.WRITE, new GrantedAuthoritySid("ROLE_USER_READ"), true); - service.updateAcl(acl); - - assertEquals(acl.getId(), 1); - assertEquals(acl.getObjectIdentity(), identity); - assertEquals(acl.getOwner(), new PrincipalSid("joe")); - assertNull(acl.getParentAcl()); - assertTrue(acl.isEntriesInheriting()); - assertEquals(2, acl.getEntries().size()); - - acl.setParent(parentAcl); - assertEquals(acl.getParentAcl(), parentAcl); - - acl.setEntriesInheriting(false); - assertFalse(acl.isEntriesInheriting()); - - ((OwnershipAcl) acl).setOwner(new PrincipalSid("ben")); - assertEquals(acl.getOwner(), new PrincipalSid("ben")); - } - - @Test - public void isSidLoadedBehavesAsExpected() throws Exception { - List loadedSids = Arrays.asList(new PrincipalSid("ben"), new GrantedAuthoritySid("ROLE_IGNORED")); - MutableAcl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, loadedSids, true, - new PrincipalSid("joe")); - - assertTrue(acl.isSidLoaded(loadedSids)); - assertTrue(acl.isSidLoaded(Arrays.asList(new GrantedAuthoritySid("ROLE_IGNORED"), new PrincipalSid("ben")))); - assertTrue(acl.isSidLoaded(Arrays.asList((Sid)new GrantedAuthoritySid("ROLE_IGNORED")))); - assertTrue(acl.isSidLoaded(BEN)); - assertTrue(acl.isSidLoaded(null)); - assertTrue(acl.isSidLoaded(new ArrayList(0))); - assertTrue(acl.isSidLoaded(Arrays.asList((Sid)new GrantedAuthoritySid("ROLE_IGNORED"), new GrantedAuthoritySid("ROLE_IGNORED")))); - assertFalse(acl.isSidLoaded(Arrays.asList((Sid)new GrantedAuthoritySid("ROLE_GENERAL"), new GrantedAuthoritySid("ROLE_IGNORED")))); - assertFalse(acl.isSidLoaded(Arrays.asList((Sid)new GrantedAuthoritySid("ROLE_IGNORED"), new GrantedAuthoritySid("ROLE_GENERAL")))); - } - - @Test(expected=NotFoundException.class) - public void insertAceRaisesNotFoundExceptionForIndexLessThanZero() throws Exception { - AclImpl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, - new PrincipalSid("joe")); - acl.insertAce(-1, mock(Permission.class), mock(Sid.class), true); - } - - @Test(expected=NotFoundException.class) - public void deleteAceRaisesNotFoundExceptionForIndexLessThanZero() throws Exception { - AclImpl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, - new PrincipalSid("joe")); - acl.deleteAce(-1); - } - - @Test(expected=NotFoundException.class) - public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize() throws Exception { - AclImpl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, - new PrincipalSid("joe")); - // Insert at zero, OK. - acl.insertAce(0, mock(Permission.class), mock(Sid.class), true); - // Size is now 1 - acl.insertAce(2, mock(Permission.class), mock(Sid.class), true); - } - - // SEC-1151 - @Test(expected=NotFoundException.class) - public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize() throws Exception { - AclImpl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, - new PrincipalSid("joe")); - acl.insertAce(0, mock(Permission.class), mock(Sid.class), true); - // Size is now 1 - acl.deleteAce(1); - } - - - //~ Inner Classes ================================================================================================== - - private class MockAclService implements MutableAclService { - public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException { - return null; - } - - public void deleteAcl(ObjectIdentity objectIdentity, boolean deleteChildren) throws ChildrenExistException { - } - - /* - * Mock implementation that populates the aces list with fully initialized AccessControlEntries - * @see org.springframework.security.acls.MutableAclService#updateAcl(org.springframework.security.acls.MutableAcl) - */ - @SuppressWarnings("unchecked") - public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { - List oldAces = acl.getEntries(); - Field acesField = FieldUtils.getField(AclImpl.class, "aces"); - acesField.setAccessible(true); - List newAces; - try { - newAces = (List) acesField.get(acl); - newAces.clear(); - - for (int i = 0; i < oldAces.size(); i++) { - AccessControlEntry ac = oldAces.get(i); - // Just give an ID to all this acl's aces, rest of the fields are just copied - newAces.add(new AccessControlEntryImpl((i + 1), ac.getAcl(), ac.getSid(), ac.getPermission(), ac - .isGranting(), ((AuditableAccessControlEntry) ac).isAuditSuccess(), - ((AuditableAccessControlEntry) ac).isAuditFailure())); - } - } - catch (IllegalAccessException e) { - e.printStackTrace(); - } - - return acl; - } - - public List findChildren(ObjectIdentity parentIdentity) { - return null; - } - - public Acl readAclById(ObjectIdentity object) throws NotFoundException { - return null; - } - - public Acl readAclById(ObjectIdentity object, List sids) throws NotFoundException { - return null; - } - - public Map readAclsById(List objects) throws NotFoundException { - return null; - } - - public Map readAclsById(List objects, List sids) throws NotFoundException { - return null; - } - } -} +package org.springframework.security.acls.domain; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.jmock.Mockery; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.springframework.security.acls.model.AccessControlEntry; +import org.springframework.security.acls.model.Acl; +import org.springframework.security.acls.model.AlreadyExistsException; +import org.springframework.security.acls.model.AuditableAccessControlEntry; +import org.springframework.security.acls.model.AuditableAcl; +import org.springframework.security.acls.model.ChildrenExistException; +import org.springframework.security.acls.model.MutableAcl; +import org.springframework.security.acls.model.MutableAclService; +import org.springframework.security.acls.model.NotFoundException; +import org.springframework.security.acls.model.ObjectIdentity; +import org.springframework.security.acls.model.OwnershipAcl; +import org.springframework.security.acls.model.Permission; +import org.springframework.security.acls.model.Sid; +import org.springframework.security.authentication.TestingAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.GrantedAuthorityImpl; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.util.FieldUtils; + + +/** + * Tests for {@link AclImpl}. + * + * @author Andrei Stefan + */ +public class AclImplTests { + private static final String TARGET_CLASS = "org.springframework.security.acls.TargetObject"; + private static final List READ = Arrays.asList(BasePermission.READ ); + private static final List WRITE = Arrays.asList(BasePermission.WRITE); + private static final List CREATE = Arrays.asList(BasePermission.CREATE ); + private static final List DELETE = Arrays.asList(BasePermission.DELETE ); + private static final List SCOTT = Arrays.asList((Sid)new PrincipalSid("scott")); + private static final List BEN = Arrays.asList((Sid)new PrincipalSid("ben")); + + Authentication auth = new TestingAuthenticationToken("joe", "ignored", "ROLE_ADMINISTRATOR"); + Mockery jmockCtx = new Mockery(); + AclAuthorizationStrategy mockAuthzStrategy; + AuditLogger mockAuditLogger; + ObjectIdentity objectIdentity = new ObjectIdentityImpl(TARGET_CLASS, 100); + + // ~ Methods ======================================================================================================== + + @Before + public void setUp() throws Exception { + SecurityContextHolder.getContext().setAuthentication(auth); + mockAuthzStrategy = mock(AclAuthorizationStrategy.class); + mockAuditLogger = mock(AuditLogger.class);; + auth.setAuthenticated(true); + } + + @After + public void tearDown() throws Exception { + SecurityContextHolder.clearContext(); + } + + @Test(expected=IllegalArgumentException.class) + public void constructorsRejectNullObjectIdentity() throws Exception { + try { + new AclImpl(null, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid("joe")); + fail("Should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + new AclImpl(null, 1, mockAuthzStrategy, mockAuditLogger); + } + + @Test(expected=IllegalArgumentException.class) + public void constructorsRejectNullId() throws Exception { + try { + new AclImpl(objectIdentity, null, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid("joe")); + fail("Should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + new AclImpl(objectIdentity, null, mockAuthzStrategy, mockAuditLogger); + } + + @Test(expected=IllegalArgumentException.class) + public void constructorsRejectNullAclAuthzStrategy() throws Exception { + try { + new AclImpl(objectIdentity, 1, null, mockAuditLogger, null, null, true, new PrincipalSid("joe")); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + new AclImpl(objectIdentity, 1, null, mockAuditLogger); + } + + @Test(expected=IllegalArgumentException.class) + public void constructorsRejectNullAuditLogger() throws Exception { + try { + new AclImpl(objectIdentity, 1, mockAuthzStrategy, null, null, null, true, new PrincipalSid("joe")); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + new AclImpl(objectIdentity, 1, mockAuthzStrategy, null); + } + + @Test + public void insertAceRejectsNullParameters() throws Exception { + MutableAcl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid( + "joe")); + try { + acl.insertAce(0, null, new GrantedAuthoritySid("ROLE_IGNORED"), true); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + try { + acl.insertAce(0, BasePermission.READ, null, true); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + } + + @Test + public void insertAceAddsElementAtCorrectIndex() throws Exception { + MutableAcl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid("joe")); + MockAclService service = new MockAclService(); + + // Insert one permission + acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST1"), true); + service.updateAcl(acl); + // Check it was successfully added + assertEquals(1, acl.getEntries().size()); + assertEquals(acl.getEntries().get(0).getAcl(), acl); + assertEquals(acl.getEntries().get(0).getPermission(), BasePermission.READ); + assertEquals(acl.getEntries().get(0).getSid(), new GrantedAuthoritySid("ROLE_TEST1")); + + // Add a second permission + acl.insertAce(1, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST2"), true); + service.updateAcl(acl); + // Check it was added on the last position + assertEquals(2, acl.getEntries().size()); + assertEquals(acl.getEntries().get(1).getAcl(), acl); + assertEquals(acl.getEntries().get(1).getPermission(), BasePermission.READ); + assertEquals(acl.getEntries().get(1).getSid(), new GrantedAuthoritySid("ROLE_TEST2")); + + // Add a third permission, after the first one + acl.insertAce(1, BasePermission.WRITE, new GrantedAuthoritySid("ROLE_TEST3"), false); + service.updateAcl(acl); + assertEquals(3, acl.getEntries().size()); + // Check the third entry was added between the two existent ones + assertEquals(acl.getEntries().get(0).getPermission(), BasePermission.READ); + assertEquals(acl.getEntries().get(0).getSid(), new GrantedAuthoritySid("ROLE_TEST1")); + assertEquals(acl.getEntries().get(1).getPermission(), BasePermission.WRITE); + assertEquals(acl.getEntries().get(1).getSid(), new GrantedAuthoritySid("ROLE_TEST3")); + assertEquals(acl.getEntries().get(2).getPermission(), BasePermission.READ); + assertEquals(acl.getEntries().get(2).getSid(), new GrantedAuthoritySid("ROLE_TEST2")); + } + + @Test(expected=NotFoundException.class) + public void insertAceFailsForNonExistentElement() throws Exception { + MutableAcl acl = new AclImpl(objectIdentity,1, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid( + "joe")); + MockAclService service = new MockAclService(); + + // Insert one permission + acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST1"), true); + service.updateAcl(acl); + + acl.insertAce(55, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST2"), true); + } + + @Test + public void deleteAceKeepsInitialOrdering() throws Exception { + MutableAcl acl = new AclImpl(objectIdentity,1, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid( + "joe")); + MockAclService service = new MockAclService(); + + // Add several permissions + acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST1"), true); + acl.insertAce(1, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST2"), true); + acl.insertAce(2, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST3"), true); + service.updateAcl(acl); + + // Delete first permission and check the order of the remaining permissions is kept + acl.deleteAce(0); + assertEquals(2, acl.getEntries().size()); + assertEquals(acl.getEntries().get(0).getSid(), new GrantedAuthoritySid("ROLE_TEST2")); + assertEquals(acl.getEntries().get(1).getSid(), new GrantedAuthoritySid("ROLE_TEST3")); + + // Add one more permission and remove the permission in the middle + acl.insertAce(2, BasePermission.READ, new GrantedAuthoritySid("ROLE_TEST4"), true); + service.updateAcl(acl); + acl.deleteAce(1); + assertEquals(2, acl.getEntries().size()); + assertEquals(acl.getEntries().get(0).getSid(), new GrantedAuthoritySid("ROLE_TEST2")); + assertEquals(acl.getEntries().get(1).getSid(), new GrantedAuthoritySid("ROLE_TEST4")); + + // Remove remaining permissions + acl.deleteAce(1); + acl.deleteAce(0); + assertEquals(0, acl.getEntries().size()); + } + + @Test + public void deleteAceFailsForNonExistentElement() throws Exception { + AclAuthorizationStrategyImpl strategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), + new GrantedAuthorityImpl("ROLE_GENERAL") }); + AuditLogger auditLogger = new ConsoleAuditLogger(); + MutableAcl acl = new AclImpl(objectIdentity, (1), strategy, auditLogger, null, null, true, new PrincipalSid( + "joe")); + try { + acl.deleteAce(99); + fail("It should have thrown NotFoundException"); + } + catch (NotFoundException expected) { + } + } + + @Test + public void isGrantingRejectsEmptyParameters() throws Exception { + MutableAcl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, new PrincipalSid( + "joe")); + Sid ben = new PrincipalSid("ben"); + try { + acl.isGranted(new ArrayList(0), Arrays.asList(ben) , false); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + try { + acl.isGranted(READ, new ArrayList(0), false); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + } + + @Test + public void isGrantingGrantsAccessForAclWithNoParent() throws Exception { + Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_GENERAL","ROLE_GUEST"); + auth.setAuthenticated(true); + SecurityContextHolder.getContext().setAuthentication(auth); + ObjectIdentity rootOid = new ObjectIdentityImpl(TARGET_CLASS, 100); + + // Create an ACL which owner is not the authenticated principal + MutableAcl rootAcl = new AclImpl(rootOid, 1, mockAuthzStrategy, mockAuditLogger, null, null, false, new PrincipalSid( + "joe")); + + // Grant some permissions + rootAcl.insertAce(0, BasePermission.READ, new PrincipalSid("ben"), false); + rootAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid("scott"), true); + rootAcl.insertAce(2, BasePermission.WRITE, new PrincipalSid("rod"), false); + rootAcl.insertAce(3, BasePermission.WRITE, new GrantedAuthoritySid("WRITE_ACCESS_ROLE"), true); + + // Check permissions granting + List permissions = Arrays.asList(BasePermission.READ, BasePermission.CREATE); + List sids = Arrays.asList(new PrincipalSid("ben"), new GrantedAuthoritySid("ROLE_GUEST")); + assertFalse(rootAcl.isGranted(permissions, sids, false)); + try { + rootAcl.isGranted(permissions, SCOTT, false); + fail("It should have thrown NotFoundException"); + } + catch (NotFoundException expected) { + } + assertTrue(rootAcl.isGranted(WRITE, SCOTT, false)); + assertFalse(rootAcl.isGranted(WRITE, + Arrays.asList(new PrincipalSid("rod"), new GrantedAuthoritySid("WRITE_ACCESS_ROLE")), false)); + assertTrue(rootAcl.isGranted(WRITE, Arrays.asList(new GrantedAuthoritySid("WRITE_ACCESS_ROLE"), new PrincipalSid("rod")), false)); + try { + // Change the type of the Sid and check the granting process + rootAcl.isGranted(WRITE, Arrays.asList(new GrantedAuthoritySid("rod"), new PrincipalSid("WRITE_ACCESS_ROLE")), false); + fail("It should have thrown NotFoundException"); + } + catch (NotFoundException expected) { + } + } + + @Test + public void isGrantingGrantsAccessForInheritableAcls() throws Exception { + Authentication auth = new TestingAuthenticationToken("ben", "ignored","ROLE_GENERAL"); + auth.setAuthenticated(true); + SecurityContextHolder.getContext().setAuthentication(auth); + ObjectIdentity grandParentOid = new ObjectIdentityImpl(TARGET_CLASS, 100); + ObjectIdentity parentOid1 = new ObjectIdentityImpl(TARGET_CLASS, 101); + ObjectIdentity parentOid2 = new ObjectIdentityImpl(TARGET_CLASS, 102); + ObjectIdentity childOid1 = new ObjectIdentityImpl(TARGET_CLASS, 103); + ObjectIdentity childOid2 = new ObjectIdentityImpl(TARGET_CLASS, 104); + + // Create ACLs + MutableAcl grandParentAcl = new AclImpl(grandParentOid, 1, mockAuthzStrategy, mockAuditLogger, null, null, false, + new PrincipalSid("joe")); + MutableAcl parentAcl1 = new AclImpl(parentOid1, 2, mockAuthzStrategy, mockAuditLogger, null, null, true, + new PrincipalSid("joe")); + MutableAcl parentAcl2 = new AclImpl(parentOid2, 3, mockAuthzStrategy, mockAuditLogger, null, null, true, + new PrincipalSid("joe")); + MutableAcl childAcl1 = new AclImpl(childOid1, 4, mockAuthzStrategy, mockAuditLogger, null, null, true, + new PrincipalSid("joe")); + MutableAcl childAcl2 = new AclImpl(childOid2, 4, mockAuthzStrategy, mockAuditLogger, null, null, false, + new PrincipalSid("joe")); + + // Create hierarchies + childAcl2.setParent(childAcl1); + childAcl1.setParent(parentAcl1); + parentAcl2.setParent(grandParentAcl); + parentAcl1.setParent(grandParentAcl); + + // Add some permissions + grandParentAcl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_USER_READ"), true); + grandParentAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid("ben"), true); + grandParentAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid("ben"), false); + grandParentAcl.insertAce(3, BasePermission.DELETE, new PrincipalSid("scott"), true); + parentAcl1.insertAce(0, BasePermission.READ, new PrincipalSid("scott"), true); + parentAcl1.insertAce(1, BasePermission.DELETE, new PrincipalSid("scott"), false); + parentAcl2.insertAce(0, BasePermission.CREATE, new PrincipalSid("ben"), true); + childAcl1.insertAce(0, BasePermission.CREATE, new PrincipalSid("scott"), true); + + // Check granting process for parent1 + assertTrue(parentAcl1.isGranted(READ, SCOTT, false)); + assertTrue(parentAcl1.isGranted(READ, Arrays.asList((Sid)new GrantedAuthoritySid("ROLE_USER_READ")), false)); + assertTrue(parentAcl1.isGranted(WRITE, BEN, false)); + assertFalse(parentAcl1.isGranted(DELETE, BEN, false)); + assertFalse(parentAcl1.isGranted(DELETE, SCOTT, false)); + + // Check granting process for parent2 + assertTrue(parentAcl2.isGranted(CREATE, BEN, false)); + assertTrue(parentAcl2.isGranted(WRITE, BEN, false)); + assertFalse(parentAcl2.isGranted(DELETE, BEN, false)); + + // Check granting process for child1 + assertTrue(childAcl1.isGranted(CREATE, SCOTT, + false)); + assertTrue(childAcl1.isGranted(READ, Arrays.asList((Sid)new GrantedAuthoritySid("ROLE_USER_READ")), false)); + assertFalse(childAcl1.isGranted(DELETE, BEN, false)); + + // Check granting process for child2 (doesn't inherit the permissions from its parent) + try { + assertTrue(childAcl2.isGranted(CREATE, SCOTT, false)); + fail("It should have thrown NotFoundException"); + } + catch (NotFoundException expected) { + assertTrue(true); + } + try { + assertTrue(childAcl2.isGranted(CREATE, Arrays.asList((Sid)new PrincipalSid("joe")), false)); + fail("It should have thrown NotFoundException"); + } + catch (NotFoundException expected) { + assertTrue(true); + } + } + + @Test + public void updatedAceValuesAreCorrectlyReflectedInAcl() throws Exception { + Authentication auth = new TestingAuthenticationToken("ben", "ignored","ROLE_GENERAL"); + auth.setAuthenticated(true); + SecurityContextHolder.getContext().setAuthentication(auth); + MutableAcl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, false, new PrincipalSid( + "joe")); + MockAclService service = new MockAclService(); + + acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_USER_READ"), true); + acl.insertAce(1, BasePermission.WRITE, new GrantedAuthoritySid("ROLE_USER_READ"), true); + acl.insertAce(2, BasePermission.CREATE, new PrincipalSid("ben"), true); + service.updateAcl(acl); + + assertEquals(acl.getEntries().get(0).getPermission(), BasePermission.READ); + assertEquals(acl.getEntries().get(1).getPermission(), BasePermission.WRITE); + assertEquals(acl.getEntries().get(2).getPermission(), BasePermission.CREATE); + + // Change each permission + acl.updateAce(0, BasePermission.CREATE); + acl.updateAce(1, BasePermission.DELETE); + acl.updateAce(2, BasePermission.READ); + + // Check the change was successfuly made + assertEquals(acl.getEntries().get(0).getPermission(), BasePermission.CREATE); + assertEquals(acl.getEntries().get(1).getPermission(), BasePermission.DELETE); + assertEquals(acl.getEntries().get(2).getPermission(), BasePermission.READ); + } + + @Test + public void auditableEntryFlagsAreUpdatedCorrectly() throws Exception { + Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_AUDITING", "ROLE_GENERAL"); + auth.setAuthenticated(true); + SecurityContextHolder.getContext().setAuthentication(auth); + MutableAcl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, false, new PrincipalSid( + "joe")); + MockAclService service = new MockAclService(); + + acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_USER_READ"), true); + acl.insertAce(1, BasePermission.WRITE, new GrantedAuthoritySid("ROLE_USER_READ"), true); + service.updateAcl(acl); + + assertFalse(((AuditableAccessControlEntry) acl.getEntries().get(0)).isAuditFailure()); + assertFalse(((AuditableAccessControlEntry) acl.getEntries().get(1)).isAuditFailure()); + assertFalse(((AuditableAccessControlEntry) acl.getEntries().get(0)).isAuditSuccess()); + assertFalse(((AuditableAccessControlEntry) acl.getEntries().get(1)).isAuditSuccess()); + + // Change each permission + ((AuditableAcl) acl).updateAuditing(0, true, true); + ((AuditableAcl) acl).updateAuditing(1, true, true); + + // Check the change was successfuly made + assertTrue(((AuditableAccessControlEntry) acl.getEntries().get(0)).isAuditFailure()); + assertTrue(((AuditableAccessControlEntry) acl.getEntries().get(1)).isAuditFailure()); + assertTrue(((AuditableAccessControlEntry) acl.getEntries().get(0)).isAuditSuccess()); + assertTrue(((AuditableAccessControlEntry) acl.getEntries().get(1)).isAuditSuccess()); + } + + @Test + public void gettersAndSettersAreConsistent() throws Exception { + Authentication auth = new TestingAuthenticationToken("ben", "ignored", new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_GENERAL") }); + auth.setAuthenticated(true); + SecurityContextHolder.getContext().setAuthentication(auth); + ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, (100)); + ObjectIdentity identity2 = new ObjectIdentityImpl(TARGET_CLASS, (101)); + MutableAcl acl = new AclImpl(identity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, + new PrincipalSid("joe")); + MutableAcl parentAcl = new AclImpl(identity2, 2, mockAuthzStrategy, mockAuditLogger, null, null, true, + new PrincipalSid("joe")); + MockAclService service = new MockAclService(); + acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_USER_READ"), true); + acl.insertAce(1, BasePermission.WRITE, new GrantedAuthoritySid("ROLE_USER_READ"), true); + service.updateAcl(acl); + + assertEquals(acl.getId(), 1); + assertEquals(acl.getObjectIdentity(), identity); + assertEquals(acl.getOwner(), new PrincipalSid("joe")); + assertNull(acl.getParentAcl()); + assertTrue(acl.isEntriesInheriting()); + assertEquals(2, acl.getEntries().size()); + + acl.setParent(parentAcl); + assertEquals(acl.getParentAcl(), parentAcl); + + acl.setEntriesInheriting(false); + assertFalse(acl.isEntriesInheriting()); + + ((OwnershipAcl) acl).setOwner(new PrincipalSid("ben")); + assertEquals(acl.getOwner(), new PrincipalSid("ben")); + } + + @Test + public void isSidLoadedBehavesAsExpected() throws Exception { + List loadedSids = Arrays.asList(new PrincipalSid("ben"), new GrantedAuthoritySid("ROLE_IGNORED")); + MutableAcl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, loadedSids, true, + new PrincipalSid("joe")); + + assertTrue(acl.isSidLoaded(loadedSids)); + assertTrue(acl.isSidLoaded(Arrays.asList(new GrantedAuthoritySid("ROLE_IGNORED"), new PrincipalSid("ben")))); + assertTrue(acl.isSidLoaded(Arrays.asList((Sid)new GrantedAuthoritySid("ROLE_IGNORED")))); + assertTrue(acl.isSidLoaded(BEN)); + assertTrue(acl.isSidLoaded(null)); + assertTrue(acl.isSidLoaded(new ArrayList(0))); + assertTrue(acl.isSidLoaded(Arrays.asList((Sid)new GrantedAuthoritySid("ROLE_IGNORED"), new GrantedAuthoritySid("ROLE_IGNORED")))); + assertFalse(acl.isSidLoaded(Arrays.asList((Sid)new GrantedAuthoritySid("ROLE_GENERAL"), new GrantedAuthoritySid("ROLE_IGNORED")))); + assertFalse(acl.isSidLoaded(Arrays.asList((Sid)new GrantedAuthoritySid("ROLE_IGNORED"), new GrantedAuthoritySid("ROLE_GENERAL")))); + } + + @Test(expected=NotFoundException.class) + public void insertAceRaisesNotFoundExceptionForIndexLessThanZero() throws Exception { + AclImpl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, + new PrincipalSid("joe")); + acl.insertAce(-1, mock(Permission.class), mock(Sid.class), true); + } + + @Test(expected=NotFoundException.class) + public void deleteAceRaisesNotFoundExceptionForIndexLessThanZero() throws Exception { + AclImpl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, + new PrincipalSid("joe")); + acl.deleteAce(-1); + } + + @Test(expected=NotFoundException.class) + public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize() throws Exception { + AclImpl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, + new PrincipalSid("joe")); + // Insert at zero, OK. + acl.insertAce(0, mock(Permission.class), mock(Sid.class), true); + // Size is now 1 + acl.insertAce(2, mock(Permission.class), mock(Sid.class), true); + } + + // SEC-1151 + @Test(expected=NotFoundException.class) + public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize() throws Exception { + AclImpl acl = new AclImpl(objectIdentity, 1, mockAuthzStrategy, mockAuditLogger, null, null, true, + new PrincipalSid("joe")); + acl.insertAce(0, mock(Permission.class), mock(Sid.class), true); + // Size is now 1 + acl.deleteAce(1); + } + + + //~ Inner Classes ================================================================================================== + + private class MockAclService implements MutableAclService { + public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException { + return null; + } + + public void deleteAcl(ObjectIdentity objectIdentity, boolean deleteChildren) throws ChildrenExistException { + } + + /* + * Mock implementation that populates the aces list with fully initialized AccessControlEntries + * @see org.springframework.security.acls.MutableAclService#updateAcl(org.springframework.security.acls.MutableAcl) + */ + @SuppressWarnings("unchecked") + public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { + List oldAces = acl.getEntries(); + Field acesField = FieldUtils.getField(AclImpl.class, "aces"); + acesField.setAccessible(true); + List newAces; + try { + newAces = (List) acesField.get(acl); + newAces.clear(); + + for (int i = 0; i < oldAces.size(); i++) { + AccessControlEntry ac = oldAces.get(i); + // Just give an ID to all this acl's aces, rest of the fields are just copied + newAces.add(new AccessControlEntryImpl((i + 1), ac.getAcl(), ac.getSid(), ac.getPermission(), ac + .isGranting(), ((AuditableAccessControlEntry) ac).isAuditSuccess(), + ((AuditableAccessControlEntry) ac).isAuditFailure())); + } + } + catch (IllegalAccessException e) { + e.printStackTrace(); + } + + return acl; + } + + public List findChildren(ObjectIdentity parentIdentity) { + return null; + } + + public Acl readAclById(ObjectIdentity object) throws NotFoundException { + return null; + } + + public Acl readAclById(ObjectIdentity object, List sids) throws NotFoundException { + return null; + } + + public Map readAclsById(List objects) throws NotFoundException { + return null; + } + + public Map readAclsById(List objects, List sids) throws NotFoundException { + return null; + } + } +} diff --git a/acl/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java b/acl/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java index 940e7c7210..a4e17458f0 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java @@ -1,260 +1,260 @@ -package org.springframework.security.acls.domain; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.springframework.security.access.AccessDeniedException; -import org.springframework.security.acls.model.Acl; -import org.springframework.security.acls.model.MutableAcl; -import org.springframework.security.acls.model.NotFoundException; -import org.springframework.security.acls.model.ObjectIdentity; -import org.springframework.security.authentication.TestingAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthorityImpl; -import org.springframework.security.core.context.SecurityContextHolder; - -/** - * Test class for {@link AclAuthorizationStrategyImpl} and {@link AclImpl} - * security checks. - * - * @author Andrei Stefan - */ -public class AclImplementationSecurityCheckTests extends TestCase { - private static final String TARGET_CLASS = "org.springframework.security.acls.TargetObject"; - - //~ Methods ======================================================================================================== - - protected void setUp() throws Exception { - SecurityContextHolder.clearContext(); - } - - protected void tearDown() throws Exception { - SecurityContextHolder.clearContext(); - } - - public void testSecurityCheckNoACEs() throws Exception { - Authentication auth = new TestingAuthenticationToken("user", "password","ROLE_GENERAL","ROLE_AUDITING","ROLE_OWNERSHIP"); - auth.setAuthenticated(true); - SecurityContextHolder.getContext().setAuthentication(auth); - - ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); - AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), - new GrantedAuthorityImpl("ROLE_GENERAL") }); - - Acl acl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); - - aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_GENERAL); - aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_AUDITING); - aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_OWNERSHIP); - - // Create another authorization strategy - AclAuthorizationStrategy aclAuthorizationStrategy2 = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO"), - new GrantedAuthorityImpl("ROLE_THREE") }); - Acl acl2 = new AclImpl(identity, new Long(1), aclAuthorizationStrategy2, new ConsoleAuditLogger()); - // Check access in case the principal has no authorization rights - try { - aclAuthorizationStrategy2.securityCheck(acl2, AclAuthorizationStrategy.CHANGE_GENERAL); - Assert.fail("It should have thrown NotFoundException"); - } - catch (NotFoundException expected) { - } - try { - aclAuthorizationStrategy2.securityCheck(acl2, AclAuthorizationStrategy.CHANGE_AUDITING); - Assert.fail("It should have thrown NotFoundException"); - } - catch (NotFoundException expected) { - } - try { - aclAuthorizationStrategy2.securityCheck(acl2, AclAuthorizationStrategy.CHANGE_OWNERSHIP); - Assert.fail("It should have thrown NotFoundException"); - } - catch (NotFoundException expected) { - } - } - - public void testSecurityCheckWithMultipleACEs() throws Exception { - // Create a simple authentication with ROLE_GENERAL - Authentication auth = new TestingAuthenticationToken("user", "password", - new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_GENERAL") }); - auth.setAuthenticated(true); - SecurityContextHolder.getContext().setAuthentication(auth); - - ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); - // Authorization strategy will require a different role for each access - AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), - new GrantedAuthorityImpl("ROLE_GENERAL") }); - - // Let's give the principal the ADMINISTRATION permission, without - // granting access - MutableAcl aclFirstDeny = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); - aclFirstDeny.insertAce(0, BasePermission.ADMINISTRATION, new PrincipalSid(auth), false); - - // The CHANGE_GENERAL test should pass as the principal has ROLE_GENERAL - aclAuthorizationStrategy.securityCheck(aclFirstDeny, AclAuthorizationStrategy.CHANGE_GENERAL); - - // The CHANGE_AUDITING and CHANGE_OWNERSHIP should fail since the - // principal doesn't have these authorities, - // nor granting access - try { - aclAuthorizationStrategy.securityCheck(aclFirstDeny, AclAuthorizationStrategy.CHANGE_AUDITING); - Assert.fail("It should have thrown AccessDeniedException"); - } - catch (AccessDeniedException expected) { - } - try { - aclAuthorizationStrategy.securityCheck(aclFirstDeny, AclAuthorizationStrategy.CHANGE_OWNERSHIP); - Assert.fail("It should have thrown AccessDeniedException"); - } - catch (AccessDeniedException expected) { - } - - // Add granting access to this principal - aclFirstDeny.insertAce(1, BasePermission.ADMINISTRATION, new PrincipalSid(auth), true); - // and try again for CHANGE_AUDITING - the first ACE's granting flag - // (false) will deny this access - try { - aclAuthorizationStrategy.securityCheck(aclFirstDeny, AclAuthorizationStrategy.CHANGE_AUDITING); - Assert.fail("It should have thrown AccessDeniedException"); - } - catch (AccessDeniedException expected) { - } - - // Create another ACL and give the principal the ADMINISTRATION - // permission, with granting access - MutableAcl aclFirstAllow = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, - new ConsoleAuditLogger()); - aclFirstAllow.insertAce(0, BasePermission.ADMINISTRATION, new PrincipalSid(auth), true); - - // The CHANGE_AUDITING test should pass as there is one ACE with - // granting access - - aclAuthorizationStrategy.securityCheck(aclFirstAllow, AclAuthorizationStrategy.CHANGE_AUDITING); - - // Add a deny ACE and test again for CHANGE_AUDITING - aclFirstAllow.insertAce(1, BasePermission.ADMINISTRATION, new PrincipalSid(auth), false); - try { - aclAuthorizationStrategy.securityCheck(aclFirstAllow, AclAuthorizationStrategy.CHANGE_AUDITING); - Assert.assertTrue(true); - } - catch (AccessDeniedException notExpected) { - Assert.fail("It shouldn't have thrown AccessDeniedException"); - } - - // Create an ACL with no ACE - MutableAcl aclNoACE = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); - try { - aclAuthorizationStrategy.securityCheck(aclNoACE, AclAuthorizationStrategy.CHANGE_AUDITING); - Assert.fail("It should have thrown NotFoundException"); - } - catch (NotFoundException expected) { - Assert.assertTrue(true); - } - // and still grant access for CHANGE_GENERAL - try { - aclAuthorizationStrategy.securityCheck(aclNoACE, AclAuthorizationStrategy.CHANGE_GENERAL); - Assert.assertTrue(true); - } - catch (NotFoundException expected) { - Assert.fail("It shouldn't have thrown NotFoundException"); - } - } - - public void testSecurityCheckWithInheritableACEs() throws Exception { - // Create a simple authentication with ROLE_GENERAL - Authentication auth = new TestingAuthenticationToken("user", "password", - new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_GENERAL") }); - auth.setAuthenticated(true); - SecurityContextHolder.getContext().setAuthentication(auth); - - ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); - // Authorization strategy will require a different role for each access - AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO"), - new GrantedAuthorityImpl("ROLE_GENERAL") }); - - // Let's give the principal an ADMINISTRATION permission, with granting - // access - MutableAcl parentAcl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); - parentAcl.insertAce(0, BasePermission.ADMINISTRATION, new PrincipalSid(auth), true); - MutableAcl childAcl = new AclImpl(identity, new Long(2), aclAuthorizationStrategy, new ConsoleAuditLogger()); - - // Check against the 'child' acl, which doesn't offer any authorization - // rights on CHANGE_OWNERSHIP - try { - aclAuthorizationStrategy.securityCheck(childAcl, AclAuthorizationStrategy.CHANGE_OWNERSHIP); - Assert.fail("It should have thrown NotFoundException"); - } - catch (NotFoundException expected) { - Assert.assertTrue(true); - } - - // Link the child with its parent and test again against the - // CHANGE_OWNERSHIP right - childAcl.setParent(parentAcl); - childAcl.setEntriesInheriting(true); - try { - aclAuthorizationStrategy.securityCheck(childAcl, AclAuthorizationStrategy.CHANGE_OWNERSHIP); - Assert.assertTrue(true); - } - catch (NotFoundException expected) { - Assert.fail("It shouldn't have thrown NotFoundException"); - } - - // Create a root parent and link it to the middle parent - MutableAcl rootParentAcl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, - new ConsoleAuditLogger()); - parentAcl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); - rootParentAcl.insertAce(0, BasePermission.ADMINISTRATION, new PrincipalSid(auth), true); - parentAcl.setEntriesInheriting(true); - parentAcl.setParent(rootParentAcl); - childAcl.setParent(parentAcl); - try { - aclAuthorizationStrategy.securityCheck(childAcl, AclAuthorizationStrategy.CHANGE_OWNERSHIP); - Assert.assertTrue(true); - } - catch (NotFoundException expected) { - Assert.fail("It shouldn't have thrown NotFoundException"); - } - } - - public void testSecurityCheckPrincipalOwner() throws Exception { - Authentication auth = new TestingAuthenticationToken("user", "password", new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_ONE"), - new GrantedAuthorityImpl("ROLE_ONE") }); - auth.setAuthenticated(true); - SecurityContextHolder.getContext().setAuthentication(auth); - - ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); - AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), - new GrantedAuthorityImpl("ROLE_GENERAL") }); - - Acl acl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger(), null, null, - false, new PrincipalSid(auth)); - try { - aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_GENERAL); - Assert.assertTrue(true); - } - catch (AccessDeniedException notExpected) { - Assert.fail("It shouldn't have thrown AccessDeniedException"); - } - try { - aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_AUDITING); - Assert.fail("It shouldn't have thrown AccessDeniedException"); - } - catch (NotFoundException expected) { - Assert.assertTrue(true); - } - try { - aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_OWNERSHIP); - Assert.assertTrue(true); - } - catch (AccessDeniedException notExpected) { - Assert.fail("It shouldn't have thrown AccessDeniedException"); - } - } -} +package org.springframework.security.acls.domain; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.springframework.security.access.AccessDeniedException; +import org.springframework.security.acls.model.Acl; +import org.springframework.security.acls.model.MutableAcl; +import org.springframework.security.acls.model.NotFoundException; +import org.springframework.security.acls.model.ObjectIdentity; +import org.springframework.security.authentication.TestingAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.GrantedAuthorityImpl; +import org.springframework.security.core.context.SecurityContextHolder; + +/** + * Test class for {@link AclAuthorizationStrategyImpl} and {@link AclImpl} + * security checks. + * + * @author Andrei Stefan + */ +public class AclImplementationSecurityCheckTests extends TestCase { + private static final String TARGET_CLASS = "org.springframework.security.acls.TargetObject"; + + //~ Methods ======================================================================================================== + + protected void setUp() throws Exception { + SecurityContextHolder.clearContext(); + } + + protected void tearDown() throws Exception { + SecurityContextHolder.clearContext(); + } + + public void testSecurityCheckNoACEs() throws Exception { + Authentication auth = new TestingAuthenticationToken("user", "password","ROLE_GENERAL","ROLE_AUDITING","ROLE_OWNERSHIP"); + auth.setAuthenticated(true); + SecurityContextHolder.getContext().setAuthentication(auth); + + ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); + AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), + new GrantedAuthorityImpl("ROLE_GENERAL") }); + + Acl acl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); + + aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_GENERAL); + aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_AUDITING); + aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_OWNERSHIP); + + // Create another authorization strategy + AclAuthorizationStrategy aclAuthorizationStrategy2 = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO"), + new GrantedAuthorityImpl("ROLE_THREE") }); + Acl acl2 = new AclImpl(identity, new Long(1), aclAuthorizationStrategy2, new ConsoleAuditLogger()); + // Check access in case the principal has no authorization rights + try { + aclAuthorizationStrategy2.securityCheck(acl2, AclAuthorizationStrategy.CHANGE_GENERAL); + Assert.fail("It should have thrown NotFoundException"); + } + catch (NotFoundException expected) { + } + try { + aclAuthorizationStrategy2.securityCheck(acl2, AclAuthorizationStrategy.CHANGE_AUDITING); + Assert.fail("It should have thrown NotFoundException"); + } + catch (NotFoundException expected) { + } + try { + aclAuthorizationStrategy2.securityCheck(acl2, AclAuthorizationStrategy.CHANGE_OWNERSHIP); + Assert.fail("It should have thrown NotFoundException"); + } + catch (NotFoundException expected) { + } + } + + public void testSecurityCheckWithMultipleACEs() throws Exception { + // Create a simple authentication with ROLE_GENERAL + Authentication auth = new TestingAuthenticationToken("user", "password", + new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_GENERAL") }); + auth.setAuthenticated(true); + SecurityContextHolder.getContext().setAuthentication(auth); + + ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); + // Authorization strategy will require a different role for each access + AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), + new GrantedAuthorityImpl("ROLE_GENERAL") }); + + // Let's give the principal the ADMINISTRATION permission, without + // granting access + MutableAcl aclFirstDeny = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); + aclFirstDeny.insertAce(0, BasePermission.ADMINISTRATION, new PrincipalSid(auth), false); + + // The CHANGE_GENERAL test should pass as the principal has ROLE_GENERAL + aclAuthorizationStrategy.securityCheck(aclFirstDeny, AclAuthorizationStrategy.CHANGE_GENERAL); + + // The CHANGE_AUDITING and CHANGE_OWNERSHIP should fail since the + // principal doesn't have these authorities, + // nor granting access + try { + aclAuthorizationStrategy.securityCheck(aclFirstDeny, AclAuthorizationStrategy.CHANGE_AUDITING); + Assert.fail("It should have thrown AccessDeniedException"); + } + catch (AccessDeniedException expected) { + } + try { + aclAuthorizationStrategy.securityCheck(aclFirstDeny, AclAuthorizationStrategy.CHANGE_OWNERSHIP); + Assert.fail("It should have thrown AccessDeniedException"); + } + catch (AccessDeniedException expected) { + } + + // Add granting access to this principal + aclFirstDeny.insertAce(1, BasePermission.ADMINISTRATION, new PrincipalSid(auth), true); + // and try again for CHANGE_AUDITING - the first ACE's granting flag + // (false) will deny this access + try { + aclAuthorizationStrategy.securityCheck(aclFirstDeny, AclAuthorizationStrategy.CHANGE_AUDITING); + Assert.fail("It should have thrown AccessDeniedException"); + } + catch (AccessDeniedException expected) { + } + + // Create another ACL and give the principal the ADMINISTRATION + // permission, with granting access + MutableAcl aclFirstAllow = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, + new ConsoleAuditLogger()); + aclFirstAllow.insertAce(0, BasePermission.ADMINISTRATION, new PrincipalSid(auth), true); + + // The CHANGE_AUDITING test should pass as there is one ACE with + // granting access + + aclAuthorizationStrategy.securityCheck(aclFirstAllow, AclAuthorizationStrategy.CHANGE_AUDITING); + + // Add a deny ACE and test again for CHANGE_AUDITING + aclFirstAllow.insertAce(1, BasePermission.ADMINISTRATION, new PrincipalSid(auth), false); + try { + aclAuthorizationStrategy.securityCheck(aclFirstAllow, AclAuthorizationStrategy.CHANGE_AUDITING); + Assert.assertTrue(true); + } + catch (AccessDeniedException notExpected) { + Assert.fail("It shouldn't have thrown AccessDeniedException"); + } + + // Create an ACL with no ACE + MutableAcl aclNoACE = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); + try { + aclAuthorizationStrategy.securityCheck(aclNoACE, AclAuthorizationStrategy.CHANGE_AUDITING); + Assert.fail("It should have thrown NotFoundException"); + } + catch (NotFoundException expected) { + Assert.assertTrue(true); + } + // and still grant access for CHANGE_GENERAL + try { + aclAuthorizationStrategy.securityCheck(aclNoACE, AclAuthorizationStrategy.CHANGE_GENERAL); + Assert.assertTrue(true); + } + catch (NotFoundException expected) { + Assert.fail("It shouldn't have thrown NotFoundException"); + } + } + + public void testSecurityCheckWithInheritableACEs() throws Exception { + // Create a simple authentication with ROLE_GENERAL + Authentication auth = new TestingAuthenticationToken("user", "password", + new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_GENERAL") }); + auth.setAuthenticated(true); + SecurityContextHolder.getContext().setAuthentication(auth); + + ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); + // Authorization strategy will require a different role for each access + AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO"), + new GrantedAuthorityImpl("ROLE_GENERAL") }); + + // Let's give the principal an ADMINISTRATION permission, with granting + // access + MutableAcl parentAcl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); + parentAcl.insertAce(0, BasePermission.ADMINISTRATION, new PrincipalSid(auth), true); + MutableAcl childAcl = new AclImpl(identity, new Long(2), aclAuthorizationStrategy, new ConsoleAuditLogger()); + + // Check against the 'child' acl, which doesn't offer any authorization + // rights on CHANGE_OWNERSHIP + try { + aclAuthorizationStrategy.securityCheck(childAcl, AclAuthorizationStrategy.CHANGE_OWNERSHIP); + Assert.fail("It should have thrown NotFoundException"); + } + catch (NotFoundException expected) { + Assert.assertTrue(true); + } + + // Link the child with its parent and test again against the + // CHANGE_OWNERSHIP right + childAcl.setParent(parentAcl); + childAcl.setEntriesInheriting(true); + try { + aclAuthorizationStrategy.securityCheck(childAcl, AclAuthorizationStrategy.CHANGE_OWNERSHIP); + Assert.assertTrue(true); + } + catch (NotFoundException expected) { + Assert.fail("It shouldn't have thrown NotFoundException"); + } + + // Create a root parent and link it to the middle parent + MutableAcl rootParentAcl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, + new ConsoleAuditLogger()); + parentAcl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); + rootParentAcl.insertAce(0, BasePermission.ADMINISTRATION, new PrincipalSid(auth), true); + parentAcl.setEntriesInheriting(true); + parentAcl.setParent(rootParentAcl); + childAcl.setParent(parentAcl); + try { + aclAuthorizationStrategy.securityCheck(childAcl, AclAuthorizationStrategy.CHANGE_OWNERSHIP); + Assert.assertTrue(true); + } + catch (NotFoundException expected) { + Assert.fail("It shouldn't have thrown NotFoundException"); + } + } + + public void testSecurityCheckPrincipalOwner() throws Exception { + Authentication auth = new TestingAuthenticationToken("user", "password", new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_ONE"), + new GrantedAuthorityImpl("ROLE_ONE") }); + auth.setAuthenticated(true); + SecurityContextHolder.getContext().setAuthentication(auth); + + ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); + AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), + new GrantedAuthorityImpl("ROLE_GENERAL") }); + + Acl acl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger(), null, null, + false, new PrincipalSid(auth)); + try { + aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_GENERAL); + Assert.assertTrue(true); + } + catch (AccessDeniedException notExpected) { + Assert.fail("It shouldn't have thrown AccessDeniedException"); + } + try { + aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_AUDITING); + Assert.fail("It shouldn't have thrown AccessDeniedException"); + } + catch (NotFoundException expected) { + Assert.assertTrue(true); + } + try { + aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_OWNERSHIP); + Assert.assertTrue(true); + } + catch (AccessDeniedException notExpected) { + Assert.fail("It shouldn't have thrown AccessDeniedException"); + } + } +} diff --git a/acl/src/test/java/org/springframework/security/acls/domain/AuditLoggerTests.java b/acl/src/test/java/org/springframework/security/acls/domain/AuditLoggerTests.java index 7f82c210d0..5e8783c125 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/AuditLoggerTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/AuditLoggerTests.java @@ -1,92 +1,91 @@ -package org.springframework.security.acls.domain; - -import static org.junit.Assert.*; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.jmock.integration.junit4.JUnit4Mockery; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.springframework.security.acls.model.AccessControlEntry; -import org.springframework.security.acls.model.AuditableAccessControlEntry; - -/** - * Test class for {@link ConsoleAuditLogger}. - * - * @author Andrei Stefan - * @version $Id$ - */ -public class AuditLoggerTests { - //~ Instance fields ================================================================================================ - private Mockery jmock = new JUnit4Mockery(); - private PrintStream console; - private ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - private ConsoleAuditLogger logger; - private AuditableAccessControlEntry ace; - private Expectations aceRequiresAudit; - private Expectations aceDoesntRequireAudit; - - //~ Methods ======================================================================================================== - - @Before - public void setUp() throws Exception { - logger = new ConsoleAuditLogger(); - ace = jmock.mock(AuditableAccessControlEntry.class); - aceRequiresAudit = new Expectations() {{ - allowing(ace).isAuditSuccess(); will(returnValue(true)); - allowing(ace).isAuditFailure(); will(returnValue(true)); - }}; - aceDoesntRequireAudit = new Expectations() {{ - allowing(ace).isAuditSuccess(); will(returnValue(false)); - allowing(ace).isAuditFailure(); will(returnValue(false)); - }}; - - console = System.out; - System.setOut(new PrintStream(bytes)); - } - - @After - public void tearDown() throws Exception { - System.setOut(console); - bytes.reset(); - } - - @Test - public void nonAuditableAceIsIgnored() { - AccessControlEntry ace = jmock.mock(AccessControlEntry.class); - logger.logIfNeeded(true, ace); - assertEquals(0, bytes.size()); - } - - @Test - public void successIsNotLoggedIfAceDoesntRequireSuccessAudit() throws Exception { - jmock.checking(aceDoesntRequireAudit); - logger.logIfNeeded(true, ace); - assertEquals(0, bytes.size()); - } - - @Test - public void successIsLoggedIfAceRequiresSuccessAudit() throws Exception { - jmock.checking(aceRequiresAudit); - logger.logIfNeeded(true, ace); - assertTrue(bytes.toString().startsWith("GRANTED due to ACE")); - } - - @Test - public void failureIsntLoggedIfAceDoesntRequireFailureAudit() throws Exception { - jmock.checking(aceDoesntRequireAudit); - logger.logIfNeeded(false, ace); - assertEquals(0, bytes.size()); - } - - @Test - public void failureIsLoggedIfAceRequiresFailureAudit() throws Exception { - jmock.checking(aceRequiresAudit); - logger.logIfNeeded(false, ace); - assertTrue(bytes.toString().startsWith("DENIED due to ACE")); - } -} +package org.springframework.security.acls.domain; + +import static org.junit.Assert.*; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +import org.jmock.Expectations; +import org.jmock.Mockery; +import org.jmock.integration.junit4.JUnit4Mockery; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.springframework.security.acls.model.AccessControlEntry; +import org.springframework.security.acls.model.AuditableAccessControlEntry; + +/** + * Test class for {@link ConsoleAuditLogger}. + * + * @author Andrei Stefan + */ +public class AuditLoggerTests { + //~ Instance fields ================================================================================================ + private Mockery jmock = new JUnit4Mockery(); + private PrintStream console; + private ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + private ConsoleAuditLogger logger; + private AuditableAccessControlEntry ace; + private Expectations aceRequiresAudit; + private Expectations aceDoesntRequireAudit; + + //~ Methods ======================================================================================================== + + @Before + public void setUp() throws Exception { + logger = new ConsoleAuditLogger(); + ace = jmock.mock(AuditableAccessControlEntry.class); + aceRequiresAudit = new Expectations() {{ + allowing(ace).isAuditSuccess(); will(returnValue(true)); + allowing(ace).isAuditFailure(); will(returnValue(true)); + }}; + aceDoesntRequireAudit = new Expectations() {{ + allowing(ace).isAuditSuccess(); will(returnValue(false)); + allowing(ace).isAuditFailure(); will(returnValue(false)); + }}; + + console = System.out; + System.setOut(new PrintStream(bytes)); + } + + @After + public void tearDown() throws Exception { + System.setOut(console); + bytes.reset(); + } + + @Test + public void nonAuditableAceIsIgnored() { + AccessControlEntry ace = jmock.mock(AccessControlEntry.class); + logger.logIfNeeded(true, ace); + assertEquals(0, bytes.size()); + } + + @Test + public void successIsNotLoggedIfAceDoesntRequireSuccessAudit() throws Exception { + jmock.checking(aceDoesntRequireAudit); + logger.logIfNeeded(true, ace); + assertEquals(0, bytes.size()); + } + + @Test + public void successIsLoggedIfAceRequiresSuccessAudit() throws Exception { + jmock.checking(aceRequiresAudit); + logger.logIfNeeded(true, ace); + assertTrue(bytes.toString().startsWith("GRANTED due to ACE")); + } + + @Test + public void failureIsntLoggedIfAceDoesntRequireFailureAudit() throws Exception { + jmock.checking(aceDoesntRequireAudit); + logger.logIfNeeded(false, ace); + assertEquals(0, bytes.size()); + } + + @Test + public void failureIsLoggedIfAceRequiresFailureAudit() throws Exception { + jmock.checking(aceRequiresAudit); + logger.logIfNeeded(false, ace); + assertTrue(bytes.toString().startsWith("DENIED due to ACE")); + } +} diff --git a/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityImplTests.java b/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityImplTests.java index 84ab828ff7..b23942e299 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityImplTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityImplTests.java @@ -1,189 +1,189 @@ -package org.springframework.security.acls.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.springframework.security.acls.domain.IdentityUnavailableException; -import org.springframework.security.acls.domain.ObjectIdentityImpl; -import org.springframework.security.acls.model.ObjectIdentity; - -/** - * Tests for {@link ObjectIdentityImpl}. - * - * @author Andrei Stefan - */ -@SuppressWarnings("unused") -public class ObjectIdentityImplTests { - - private static final String DOMAIN_CLASS = - "org.springframework.security.acls.domain.ObjectIdentityImplTests$MockIdDomainObject"; - - //~ Methods ======================================================================================================== - - @Test - public void constructorsRespectRequiredFields() throws Exception { - // Check one-argument constructor required field - try { - new ObjectIdentityImpl(null); - fail("It should have thrown IllegalArgumentException"); - } catch (IllegalArgumentException expected) { - } - - // Check String-Serializable constructor required field - try { - new ObjectIdentityImpl("", Long.valueOf(1)); - fail("It should have thrown IllegalArgumentException"); - } catch (IllegalArgumentException expected) { - } - - // Check Serializable parameter is not null - try { - new ObjectIdentityImpl(DOMAIN_CLASS, null); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - - // The correct way of using String-Serializable constructor - try { - new ObjectIdentityImpl(DOMAIN_CLASS, Long.valueOf(1)); - } - catch (IllegalArgumentException notExpected) { - fail("It shouldn't have thrown IllegalArgumentException"); - } - - // Check the Class-Serializable constructor - try { - new ObjectIdentityImpl(MockIdDomainObject.class, null); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - } - - @Test - public void gettersReturnExpectedValues() throws Exception { - ObjectIdentity obj = new ObjectIdentityImpl(DOMAIN_CLASS, Long.valueOf(1)); - assertEquals(Long.valueOf(1), obj.getIdentifier()); - assertEquals(MockIdDomainObject.class.getName(), obj.getType()); - } - - @Test - public void testGetIdMethodConstraints() throws Exception { - // Check the getId() method is present - try { - new ObjectIdentityImpl("A_STRING_OBJECT"); - fail("It should have thrown IdentityUnavailableException"); - } - catch (IdentityUnavailableException expected) { - - } - - // getId() should return a non-null value - MockIdDomainObject mockId = new MockIdDomainObject(); - try { - new ObjectIdentityImpl(mockId); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - - } - - // getId() should return a Serializable object - mockId.setId(new MockIdDomainObject()); - try { - new ObjectIdentityImpl(mockId); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - } - - // getId() should return a Serializable object - mockId.setId(new Long(100)); - try { - new ObjectIdentityImpl(mockId); - } - catch (IllegalArgumentException expected) { - } - } - - @Test(expected=IllegalArgumentException.class) - public void constructorRejectsInvalidTypeParameter() throws Exception { - new ObjectIdentityImpl("", Long.valueOf(1)); - } - - @Test - public void testEquals() throws Exception { - ObjectIdentity obj = new ObjectIdentityImpl(DOMAIN_CLASS, Long.valueOf(1)); - MockIdDomainObject mockObj = new MockIdDomainObject(); - mockObj.setId(Long.valueOf(1)); - - String string = "SOME_STRING"; - assertNotSame(obj, string); - assertFalse(obj.equals(null)); - assertFalse(obj.equals("DIFFERENT_OBJECT_TYPE")); - assertFalse(obj.equals(new ObjectIdentityImpl(DOMAIN_CLASS, Long.valueOf(2)))); - assertFalse(obj.equals(new ObjectIdentityImpl( - "org.springframework.security.acls.domain.ObjectIdentityImplTests$MockOtherIdDomainObject", - Long.valueOf(1)))); - assertEquals(new ObjectIdentityImpl(DOMAIN_CLASS,Long.valueOf(1)), obj); - assertEquals(obj, new ObjectIdentityImpl(mockObj)); - } - - @Test - public void hashcodeIsDifferentForDifferentJavaTypes() throws Exception { - ObjectIdentity obj = new ObjectIdentityImpl(Object.class, Long.valueOf(1)); - ObjectIdentity obj2 = new ObjectIdentityImpl(String.class, Long.valueOf(1)); - assertFalse(obj.hashCode() == obj2.hashCode()); - } - - @Test - public void longAndIntegerIdsWithSameValueAreEqualAndHaveSameHashcode() { - ObjectIdentity obj = new ObjectIdentityImpl(Object.class, new Long(5)); - ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, new Integer(5)); - - assertEquals(obj, obj2); - assertEquals(obj.hashCode(), obj2.hashCode()); - } - - @Test - public void equalStringIdsAreEqualAndHaveSameHashcode() throws Exception { - ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000"); - ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, "1000"); - assertEquals(obj, obj2); - assertEquals(obj.hashCode(), obj2.hashCode()); - } - - @Test - public void stringAndNumericIdsAreNotEqual() throws Exception { - ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000"); - ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, Long.valueOf(1000)); - assertFalse(obj.equals(obj2)); - } - - //~ Inner Classes ================================================================================================== - - private class MockIdDomainObject { - private Object id; - - public Object getId() { - return id; - } - - public void setId(Object id) { - this.id = id; - } - } - - private class MockOtherIdDomainObject { - private Object id; - - public Object getId() { - return id; - } - - public void setId(Object id) { - this.id = id; - } - } -} +package org.springframework.security.acls.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.springframework.security.acls.domain.IdentityUnavailableException; +import org.springframework.security.acls.domain.ObjectIdentityImpl; +import org.springframework.security.acls.model.ObjectIdentity; + +/** + * Tests for {@link ObjectIdentityImpl}. + * + * @author Andrei Stefan + */ +@SuppressWarnings("unused") +public class ObjectIdentityImplTests { + + private static final String DOMAIN_CLASS = + "org.springframework.security.acls.domain.ObjectIdentityImplTests$MockIdDomainObject"; + + //~ Methods ======================================================================================================== + + @Test + public void constructorsRespectRequiredFields() throws Exception { + // Check one-argument constructor required field + try { + new ObjectIdentityImpl(null); + fail("It should have thrown IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + + // Check String-Serializable constructor required field + try { + new ObjectIdentityImpl("", Long.valueOf(1)); + fail("It should have thrown IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + + // Check Serializable parameter is not null + try { + new ObjectIdentityImpl(DOMAIN_CLASS, null); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + + // The correct way of using String-Serializable constructor + try { + new ObjectIdentityImpl(DOMAIN_CLASS, Long.valueOf(1)); + } + catch (IllegalArgumentException notExpected) { + fail("It shouldn't have thrown IllegalArgumentException"); + } + + // Check the Class-Serializable constructor + try { + new ObjectIdentityImpl(MockIdDomainObject.class, null); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + } + + @Test + public void gettersReturnExpectedValues() throws Exception { + ObjectIdentity obj = new ObjectIdentityImpl(DOMAIN_CLASS, Long.valueOf(1)); + assertEquals(Long.valueOf(1), obj.getIdentifier()); + assertEquals(MockIdDomainObject.class.getName(), obj.getType()); + } + + @Test + public void testGetIdMethodConstraints() throws Exception { + // Check the getId() method is present + try { + new ObjectIdentityImpl("A_STRING_OBJECT"); + fail("It should have thrown IdentityUnavailableException"); + } + catch (IdentityUnavailableException expected) { + + } + + // getId() should return a non-null value + MockIdDomainObject mockId = new MockIdDomainObject(); + try { + new ObjectIdentityImpl(mockId); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + + } + + // getId() should return a Serializable object + mockId.setId(new MockIdDomainObject()); + try { + new ObjectIdentityImpl(mockId); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + } + + // getId() should return a Serializable object + mockId.setId(new Long(100)); + try { + new ObjectIdentityImpl(mockId); + } + catch (IllegalArgumentException expected) { + } + } + + @Test(expected=IllegalArgumentException.class) + public void constructorRejectsInvalidTypeParameter() throws Exception { + new ObjectIdentityImpl("", Long.valueOf(1)); + } + + @Test + public void testEquals() throws Exception { + ObjectIdentity obj = new ObjectIdentityImpl(DOMAIN_CLASS, Long.valueOf(1)); + MockIdDomainObject mockObj = new MockIdDomainObject(); + mockObj.setId(Long.valueOf(1)); + + String string = "SOME_STRING"; + assertNotSame(obj, string); + assertFalse(obj.equals(null)); + assertFalse(obj.equals("DIFFERENT_OBJECT_TYPE")); + assertFalse(obj.equals(new ObjectIdentityImpl(DOMAIN_CLASS, Long.valueOf(2)))); + assertFalse(obj.equals(new ObjectIdentityImpl( + "org.springframework.security.acls.domain.ObjectIdentityImplTests$MockOtherIdDomainObject", + Long.valueOf(1)))); + assertEquals(new ObjectIdentityImpl(DOMAIN_CLASS,Long.valueOf(1)), obj); + assertEquals(obj, new ObjectIdentityImpl(mockObj)); + } + + @Test + public void hashcodeIsDifferentForDifferentJavaTypes() throws Exception { + ObjectIdentity obj = new ObjectIdentityImpl(Object.class, Long.valueOf(1)); + ObjectIdentity obj2 = new ObjectIdentityImpl(String.class, Long.valueOf(1)); + assertFalse(obj.hashCode() == obj2.hashCode()); + } + + @Test + public void longAndIntegerIdsWithSameValueAreEqualAndHaveSameHashcode() { + ObjectIdentity obj = new ObjectIdentityImpl(Object.class, new Long(5)); + ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, new Integer(5)); + + assertEquals(obj, obj2); + assertEquals(obj.hashCode(), obj2.hashCode()); + } + + @Test + public void equalStringIdsAreEqualAndHaveSameHashcode() throws Exception { + ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000"); + ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, "1000"); + assertEquals(obj, obj2); + assertEquals(obj.hashCode(), obj2.hashCode()); + } + + @Test + public void stringAndNumericIdsAreNotEqual() throws Exception { + ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000"); + ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, Long.valueOf(1000)); + assertFalse(obj.equals(obj2)); + } + + //~ Inner Classes ================================================================================================== + + private class MockIdDomainObject { + private Object id; + + public Object getId() { + return id; + } + + public void setId(Object id) { + this.id = id; + } + } + + private class MockOtherIdDomainObject { + private Object id; + + public Object getId() { + return id; + } + + public void setId(Object id) { + this.id = id; + } + } +} diff --git a/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImplTests.java b/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImplTests.java index ed0c250530..e9f7f9e588 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImplTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImplTests.java @@ -1,42 +1,42 @@ -package org.springframework.security.acls.domain; - -import org.springframework.security.acls.domain.ObjectIdentityImpl; -import org.springframework.security.acls.domain.ObjectIdentityRetrievalStrategyImpl; -import org.springframework.security.acls.model.ObjectIdentity; -import org.springframework.security.acls.model.ObjectIdentityRetrievalStrategy; - -import junit.framework.TestCase; - -/** - * Tests for {@link ObjectIdentityRetrievalStrategyImpl} - * - * @author Andrei Stefan - */ -public class ObjectIdentityRetrievalStrategyImplTests extends TestCase { - //~ Methods ======================================================================================================== - - public void testObjectIdentityCreation() throws Exception { - MockIdDomainObject domain = new MockIdDomainObject(); - domain.setId(new Integer(1)); - - ObjectIdentityRetrievalStrategy retStrategy = new ObjectIdentityRetrievalStrategyImpl(); - ObjectIdentity identity = retStrategy.getObjectIdentity(domain); - - assertNotNull(identity); - assertEquals(identity, new ObjectIdentityImpl(domain)); - } - - //~ Inner Classes ================================================================================================== - @SuppressWarnings("unused") - private class MockIdDomainObject { - private Object id; - - public Object getId() { - return id; - } - - public void setId(Object id) { - this.id = id; - } - } -} +package org.springframework.security.acls.domain; + +import org.springframework.security.acls.domain.ObjectIdentityImpl; +import org.springframework.security.acls.domain.ObjectIdentityRetrievalStrategyImpl; +import org.springframework.security.acls.model.ObjectIdentity; +import org.springframework.security.acls.model.ObjectIdentityRetrievalStrategy; + +import junit.framework.TestCase; + +/** + * Tests for {@link ObjectIdentityRetrievalStrategyImpl} + * + * @author Andrei Stefan + */ +public class ObjectIdentityRetrievalStrategyImplTests extends TestCase { + //~ Methods ======================================================================================================== + + public void testObjectIdentityCreation() throws Exception { + MockIdDomainObject domain = new MockIdDomainObject(); + domain.setId(new Integer(1)); + + ObjectIdentityRetrievalStrategy retStrategy = new ObjectIdentityRetrievalStrategyImpl(); + ObjectIdentity identity = retStrategy.getObjectIdentity(domain); + + assertNotNull(identity); + assertEquals(identity, new ObjectIdentityImpl(domain)); + } + + //~ Inner Classes ================================================================================================== + @SuppressWarnings("unused") + private class MockIdDomainObject { + private Object id; + + public Object getId() { + return id; + } + + public void setId(Object id) { + this.id = id; + } + } +} diff --git a/acl/src/test/java/org/springframework/security/acls/domain/PermissionTests.java b/acl/src/test/java/org/springframework/security/acls/domain/PermissionTests.java index ddf837c970..c9c383c721 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/PermissionTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/PermissionTests.java @@ -25,7 +25,6 @@ import org.springframework.security.acls.model.Permission; * Tests classes associated with Permission. * * @author Ben Alex - * @version $Id$ */ public class PermissionTests { diff --git a/acl/src/test/java/org/springframework/security/acls/domain/SpecialPermission.java b/acl/src/test/java/org/springframework/security/acls/domain/SpecialPermission.java index 3ed3c7026d..2582e76495 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/SpecialPermission.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/SpecialPermission.java @@ -21,7 +21,6 @@ import org.springframework.security.acls.model.Permission; * A test permission. * * @author Ben Alex - * @version $Id$ */ public class SpecialPermission extends BasePermission { public static final Permission ENTER = new SpecialPermission(1 << 5, 'E'); // 32 diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyTests.java b/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyTests.java index dfe97aace4..e931138cde 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyTests.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyTests.java @@ -1,312 +1,312 @@ -package org.springframework.security.acls.jdbc; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import junit.framework.Assert; -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.datasource.SingleConnectionDataSource; -import org.springframework.security.acls.domain.AclAuthorizationStrategy; -import org.springframework.security.acls.domain.AclAuthorizationStrategyImpl; -import org.springframework.security.acls.domain.BasePermission; -import org.springframework.security.acls.domain.ConsoleAuditLogger; -import org.springframework.security.acls.domain.DefaultPermissionFactory; -import org.springframework.security.acls.domain.EhCacheBasedAclCache; -import org.springframework.security.acls.domain.ObjectIdentityImpl; -import org.springframework.security.acls.domain.PrincipalSid; -import org.springframework.security.acls.model.Acl; -import org.springframework.security.acls.model.AuditableAccessControlEntry; -import org.springframework.security.acls.model.MutableAcl; -import org.springframework.security.acls.model.NotFoundException; -import org.springframework.security.acls.model.ObjectIdentity; -import org.springframework.security.acls.model.Permission; -import org.springframework.security.acls.model.Sid; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthorityImpl; -import org.springframework.util.FileCopyUtils; - -/** - * Tests {@link BasicLookupStrategy} - * - * @author Andrei Stefan - */ -public class BasicLookupStrategyTests { - - private static final Sid BEN_SID = new PrincipalSid("ben"); - private static final String TARGET_CLASS = "org.springframework.security.acls.TargetObject"; - - //~ Instance fields ================================================================================================ - - private static JdbcTemplate jdbcTemplate; - private BasicLookupStrategy strategy; - private static SingleConnectionDataSource dataSource; - private static CacheManager cacheManager; - - //~ Methods ======================================================================================================== - @BeforeClass - public static void initCacheManaer() { - cacheManager = new CacheManager(); - cacheManager.addCache(new Cache("basiclookuptestcache", 500, false, false, 30, 30)); - } - - @BeforeClass - public static void createDatabase() throws Exception { - dataSource = new SingleConnectionDataSource("jdbc:hsqldb:mem:lookupstrategytest", "sa", "", true); - dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); - jdbcTemplate = new JdbcTemplate(dataSource); - - Resource resource = new ClassPathResource("createAclSchema.sql"); - String sql = new String(FileCopyUtils.copyToByteArray(resource.getInputStream())); - jdbcTemplate.execute(sql); - } - - @AfterClass - public static void dropDatabase() throws Exception { - dataSource.destroy(); - } - - @AfterClass - public static void shutdownCacheManager() { - cacheManager.removalAll(); - cacheManager.shutdown(); - } - - @Before - public void populateDatabase() { - String query = "INSERT INTO acl_sid(ID,PRINCIPAL,SID) VALUES (1,1,'ben');" - + "INSERT INTO acl_class(ID,CLASS) VALUES (2,'" + TARGET_CLASS + "');" - + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (1,2,100,null,1,1);" - + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (2,2,101,1,1,1);" - + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (3,2,102,2,1,1);" - + "INSERT INTO acl_entry(ID,ACL_OBJECT_IDENTITY,ACE_ORDER,SID,MASK,GRANTING,AUDIT_SUCCESS,AUDIT_FAILURE) VALUES (1,1,0,1,1,1,0,0);" - + "INSERT INTO acl_entry(ID,ACL_OBJECT_IDENTITY,ACE_ORDER,SID,MASK,GRANTING,AUDIT_SUCCESS,AUDIT_FAILURE) VALUES (2,1,1,1,2,0,0,0);" - + "INSERT INTO acl_entry(ID,ACL_OBJECT_IDENTITY,ACE_ORDER,SID,MASK,GRANTING,AUDIT_SUCCESS,AUDIT_FAILURE) VALUES (3,2,0,1,8,1,0,0);" - + "INSERT INTO acl_entry(ID,ACL_OBJECT_IDENTITY,ACE_ORDER,SID,MASK,GRANTING,AUDIT_SUCCESS,AUDIT_FAILURE) VALUES (4,3,0,1,8,0,0,0);"; - jdbcTemplate.execute(query); - } - - @Before - public void initializeBeans() { - EhCacheBasedAclCache cache = new EhCacheBasedAclCache(getCache()); - AclAuthorizationStrategy authorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_ADMINISTRATOR"), new GrantedAuthorityImpl("ROLE_ADMINISTRATOR"), - new GrantedAuthorityImpl("ROLE_ADMINISTRATOR") }); - strategy = new BasicLookupStrategy(dataSource, cache, authorizationStrategy, new ConsoleAuditLogger()); - strategy.setPermissionFactory(new DefaultPermissionFactory()); - } - - @After - public void emptyDatabase() { - String query = "DELETE FROM acl_entry;" + "DELETE FROM acl_object_identity WHERE ID = 7;" - + "DELETE FROM acl_object_identity WHERE ID = 6;" + "DELETE FROM acl_object_identity WHERE ID = 5;" - + "DELETE FROM acl_object_identity WHERE ID = 4;" + "DELETE FROM acl_object_identity WHERE ID = 3;" - + "DELETE FROM acl_object_identity WHERE ID = 2;" + "DELETE FROM acl_object_identity WHERE ID = 1;" - + "DELETE FROM acl_class;" + "DELETE FROM acl_sid;"; - jdbcTemplate.execute(query); - } - - private Ehcache getCache() { - Ehcache cache = cacheManager.getCache("basiclookuptestcache"); - cache.removeAll(); - return cache; - } - - @Test - public void testAclsRetrievalWithDefaultBatchSize() throws Exception { - ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); - ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(101)); - // Deliberately use an integer for the child, to reproduce bug report in SEC-819 - ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(102)); - - Map map = this.strategy.readAclsById(Arrays.asList(topParentOid, middleParentOid, childOid), null); - checkEntries(topParentOid, middleParentOid, childOid, map); - } - - @Test - public void testAclsRetrievalFromCacheOnly() throws Exception { - ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(100)); - ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(101)); - ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(102)); - - // Objects were put in cache - strategy.readAclsById(Arrays.asList(topParentOid, middleParentOid, childOid), null); - - // Let's empty the database to force acls retrieval from cache - emptyDatabase(); - Map map = this.strategy.readAclsById(Arrays.asList(topParentOid, middleParentOid, childOid), null); - - checkEntries(topParentOid, middleParentOid, childOid, map); - } - - @Test - public void testAclsRetrievalWithCustomBatchSize() throws Exception { - ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); - ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(101)); - ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(102)); - - // Set a batch size to allow multiple database queries in order to retrieve all acls - ((BasicLookupStrategy) this.strategy).setBatchSize(1); - Map map = this.strategy.readAclsById(Arrays.asList(topParentOid, middleParentOid, childOid), null); - checkEntries(topParentOid, middleParentOid, childOid, map); - } - - private void checkEntries(ObjectIdentity topParentOid, ObjectIdentity middleParentOid, ObjectIdentity childOid, - Map map) throws Exception { - Assert.assertEquals(3, map.size()); - - MutableAcl topParent = (MutableAcl) map.get(topParentOid); - MutableAcl middleParent = (MutableAcl) map.get(middleParentOid); - MutableAcl child = (MutableAcl) map.get(childOid); - - // Check the retrieved versions has IDs - Assert.assertNotNull(topParent.getId()); - Assert.assertNotNull(middleParent.getId()); - Assert.assertNotNull(child.getId()); - - // Check their parents were correctly retrieved - Assert.assertNull(topParent.getParentAcl()); - Assert.assertEquals(topParentOid, middleParent.getParentAcl().getObjectIdentity()); - Assert.assertEquals(middleParentOid, child.getParentAcl().getObjectIdentity()); - - // Check their ACEs were correctly retrieved - Assert.assertEquals(2, topParent.getEntries().size()); - Assert.assertEquals(1, middleParent.getEntries().size()); - Assert.assertEquals(1, child.getEntries().size()); - - // Check object identities were correctly retrieved - Assert.assertEquals(topParentOid, topParent.getObjectIdentity()); - Assert.assertEquals(middleParentOid, middleParent.getObjectIdentity()); - Assert.assertEquals(childOid, child.getObjectIdentity()); - - // Check each entry - Assert.assertTrue(topParent.isEntriesInheriting()); - Assert.assertEquals(topParent.getId(), new Long(1)); - Assert.assertEquals(topParent.getOwner(), new PrincipalSid("ben")); - Assert.assertEquals(topParent.getEntries().get(0).getId(), new Long(1)); - Assert.assertEquals(topParent.getEntries().get(0).getPermission(), BasePermission.READ); - Assert.assertEquals(topParent.getEntries().get(0).getSid(), new PrincipalSid("ben")); - Assert.assertFalse(((AuditableAccessControlEntry) topParent.getEntries().get(0)).isAuditFailure()); - Assert.assertFalse(((AuditableAccessControlEntry) topParent.getEntries().get(0)).isAuditSuccess()); - Assert.assertTrue(((AuditableAccessControlEntry) topParent.getEntries().get(0)).isGranting()); - - Assert.assertEquals(topParent.getEntries().get(1).getId(), new Long(2)); - Assert.assertEquals(topParent.getEntries().get(1).getPermission(), BasePermission.WRITE); - Assert.assertEquals(topParent.getEntries().get(1).getSid(), new PrincipalSid("ben")); - Assert.assertFalse(((AuditableAccessControlEntry) topParent.getEntries().get(1)).isAuditFailure()); - Assert.assertFalse(((AuditableAccessControlEntry) topParent.getEntries().get(1)).isAuditSuccess()); - Assert.assertFalse(((AuditableAccessControlEntry) topParent.getEntries().get(1)).isGranting()); - - Assert.assertTrue(middleParent.isEntriesInheriting()); - Assert.assertEquals(middleParent.getId(), new Long(2)); - Assert.assertEquals(middleParent.getOwner(), new PrincipalSid("ben")); - Assert.assertEquals(middleParent.getEntries().get(0).getId(), new Long(3)); - Assert.assertEquals(middleParent.getEntries().get(0).getPermission(), BasePermission.DELETE); - Assert.assertEquals(middleParent.getEntries().get(0).getSid(), new PrincipalSid("ben")); - Assert.assertFalse(((AuditableAccessControlEntry) middleParent.getEntries().get(0)).isAuditFailure()); - Assert.assertFalse(((AuditableAccessControlEntry) middleParent.getEntries().get(0)).isAuditSuccess()); - Assert.assertTrue(((AuditableAccessControlEntry) middleParent.getEntries().get(0)).isGranting()); - - Assert.assertTrue(child.isEntriesInheriting()); - Assert.assertEquals(child.getId(), new Long(3)); - Assert.assertEquals(child.getOwner(), new PrincipalSid("ben")); - Assert.assertEquals(child.getEntries().get(0).getId(), new Long(4)); - Assert.assertEquals(child.getEntries().get(0).getPermission(), BasePermission.DELETE); - Assert.assertEquals(child.getEntries().get(0).getSid(), new PrincipalSid("ben")); - Assert.assertFalse(((AuditableAccessControlEntry) child.getEntries().get(0)).isAuditFailure()); - Assert.assertFalse(((AuditableAccessControlEntry) child.getEntries().get(0)).isAuditSuccess()); - Assert.assertFalse((child.getEntries().get(0)).isGranting()); - } - - @Test - public void testAllParentsAreRetrievedWhenChildIsLoaded() throws Exception { - String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (4,2,103,1,1,1);"; - jdbcTemplate.execute(query); - - ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); - ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(101)); - ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(102)); - ObjectIdentity middleParent2Oid = new ObjectIdentityImpl(TARGET_CLASS, new Long(103)); - - // Retrieve the child - Map map = this.strategy.readAclsById(Arrays.asList(childOid), null); - - // Check that the child and all its parents were retrieved - Assert.assertNotNull(map.get(childOid)); - Assert.assertEquals(childOid, ((Acl) map.get(childOid)).getObjectIdentity()); - Assert.assertNotNull(map.get(middleParentOid)); - Assert.assertEquals(middleParentOid, ((Acl) map.get(middleParentOid)).getObjectIdentity()); - Assert.assertNotNull(map.get(topParentOid)); - Assert.assertEquals(topParentOid, ((Acl) map.get(topParentOid)).getObjectIdentity()); - - // The second parent shouldn't have been retrieved - Assert.assertNull(map.get(middleParent2Oid)); - } - - /** - * Test created from SEC-590. - */ - @Test - public void testReadAllObjectIdentitiesWhenLastElementIsAlreadyCached() throws Exception { - String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (4,2,104,null,1,1);" - + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (5,2,105,4,1,1);" - + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (6,2,106,4,1,1);" - + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (7,2,107,5,1,1);" - + "INSERT INTO acl_entry(ID,ACL_OBJECT_IDENTITY,ACE_ORDER,SID,MASK,GRANTING,AUDIT_SUCCESS,AUDIT_FAILURE) VALUES (5,4,0,1,1,1,0,0)"; - jdbcTemplate.execute(query); - - ObjectIdentity grandParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(104)); - ObjectIdentity parent1Oid = new ObjectIdentityImpl(TARGET_CLASS, new Long(105)); - ObjectIdentity parent2Oid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(106)); - ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(107)); - - // First lookup only child, thus populating the cache with grandParent, parent1 and child - List checkPermission = Arrays.asList(BasePermission.READ); - List sids = Arrays.asList(BEN_SID); - List childOids = Arrays.asList(childOid); - - strategy.setBatchSize(6); - Map foundAcls = strategy.readAclsById(childOids, sids); - - Acl foundChildAcl = (Acl) foundAcls.get(childOid); - Assert.assertNotNull(foundChildAcl); - Assert.assertTrue(foundChildAcl.isGranted(checkPermission, sids, false)); - - // Search for object identities has to be done in the following order: last element have to be one which - // is already in cache and the element before it must not be stored in cache - List allOids = Arrays.asList(grandParentOid, parent1Oid, parent2Oid, childOid); - try { - foundAcls = strategy.readAclsById(allOids, sids); - Assert.assertTrue(true); - } catch (NotFoundException notExpected) { - Assert.fail("It shouldn't have thrown NotFoundException"); - } - - Acl foundParent2Acl = (Acl) foundAcls.get(parent2Oid); - Assert.assertNotNull(foundParent2Acl); - Assert.assertTrue(foundParent2Acl.isGranted(checkPermission, sids, false)); - } - - @Test(expected=IllegalArgumentException.class) - public void nullOwnerIsNotSupported() { - String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (4,2,104,null,null,1);"; - - jdbcTemplate.execute(query); - - ObjectIdentity oid = new ObjectIdentityImpl(TARGET_CLASS, new Long(104)); - - strategy.readAclsById(Arrays.asList(oid), Arrays.asList(BEN_SID)); - } - -} +package org.springframework.security.acls.jdbc; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import junit.framework.Assert; +import net.sf.ehcache.Cache; +import net.sf.ehcache.CacheManager; +import net.sf.ehcache.Ehcache; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.datasource.SingleConnectionDataSource; +import org.springframework.security.acls.domain.AclAuthorizationStrategy; +import org.springframework.security.acls.domain.AclAuthorizationStrategyImpl; +import org.springframework.security.acls.domain.BasePermission; +import org.springframework.security.acls.domain.ConsoleAuditLogger; +import org.springframework.security.acls.domain.DefaultPermissionFactory; +import org.springframework.security.acls.domain.EhCacheBasedAclCache; +import org.springframework.security.acls.domain.ObjectIdentityImpl; +import org.springframework.security.acls.domain.PrincipalSid; +import org.springframework.security.acls.model.Acl; +import org.springframework.security.acls.model.AuditableAccessControlEntry; +import org.springframework.security.acls.model.MutableAcl; +import org.springframework.security.acls.model.NotFoundException; +import org.springframework.security.acls.model.ObjectIdentity; +import org.springframework.security.acls.model.Permission; +import org.springframework.security.acls.model.Sid; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.GrantedAuthorityImpl; +import org.springframework.util.FileCopyUtils; + +/** + * Tests {@link BasicLookupStrategy} + * + * @author Andrei Stefan + */ +public class BasicLookupStrategyTests { + + private static final Sid BEN_SID = new PrincipalSid("ben"); + private static final String TARGET_CLASS = "org.springframework.security.acls.TargetObject"; + + //~ Instance fields ================================================================================================ + + private static JdbcTemplate jdbcTemplate; + private BasicLookupStrategy strategy; + private static SingleConnectionDataSource dataSource; + private static CacheManager cacheManager; + + //~ Methods ======================================================================================================== + @BeforeClass + public static void initCacheManaer() { + cacheManager = new CacheManager(); + cacheManager.addCache(new Cache("basiclookuptestcache", 500, false, false, 30, 30)); + } + + @BeforeClass + public static void createDatabase() throws Exception { + dataSource = new SingleConnectionDataSource("jdbc:hsqldb:mem:lookupstrategytest", "sa", "", true); + dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); + jdbcTemplate = new JdbcTemplate(dataSource); + + Resource resource = new ClassPathResource("createAclSchema.sql"); + String sql = new String(FileCopyUtils.copyToByteArray(resource.getInputStream())); + jdbcTemplate.execute(sql); + } + + @AfterClass + public static void dropDatabase() throws Exception { + dataSource.destroy(); + } + + @AfterClass + public static void shutdownCacheManager() { + cacheManager.removalAll(); + cacheManager.shutdown(); + } + + @Before + public void populateDatabase() { + String query = "INSERT INTO acl_sid(ID,PRINCIPAL,SID) VALUES (1,1,'ben');" + + "INSERT INTO acl_class(ID,CLASS) VALUES (2,'" + TARGET_CLASS + "');" + + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (1,2,100,null,1,1);" + + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (2,2,101,1,1,1);" + + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (3,2,102,2,1,1);" + + "INSERT INTO acl_entry(ID,ACL_OBJECT_IDENTITY,ACE_ORDER,SID,MASK,GRANTING,AUDIT_SUCCESS,AUDIT_FAILURE) VALUES (1,1,0,1,1,1,0,0);" + + "INSERT INTO acl_entry(ID,ACL_OBJECT_IDENTITY,ACE_ORDER,SID,MASK,GRANTING,AUDIT_SUCCESS,AUDIT_FAILURE) VALUES (2,1,1,1,2,0,0,0);" + + "INSERT INTO acl_entry(ID,ACL_OBJECT_IDENTITY,ACE_ORDER,SID,MASK,GRANTING,AUDIT_SUCCESS,AUDIT_FAILURE) VALUES (3,2,0,1,8,1,0,0);" + + "INSERT INTO acl_entry(ID,ACL_OBJECT_IDENTITY,ACE_ORDER,SID,MASK,GRANTING,AUDIT_SUCCESS,AUDIT_FAILURE) VALUES (4,3,0,1,8,0,0,0);"; + jdbcTemplate.execute(query); + } + + @Before + public void initializeBeans() { + EhCacheBasedAclCache cache = new EhCacheBasedAclCache(getCache()); + AclAuthorizationStrategy authorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_ADMINISTRATOR"), new GrantedAuthorityImpl("ROLE_ADMINISTRATOR"), + new GrantedAuthorityImpl("ROLE_ADMINISTRATOR") }); + strategy = new BasicLookupStrategy(dataSource, cache, authorizationStrategy, new ConsoleAuditLogger()); + strategy.setPermissionFactory(new DefaultPermissionFactory()); + } + + @After + public void emptyDatabase() { + String query = "DELETE FROM acl_entry;" + "DELETE FROM acl_object_identity WHERE ID = 7;" + + "DELETE FROM acl_object_identity WHERE ID = 6;" + "DELETE FROM acl_object_identity WHERE ID = 5;" + + "DELETE FROM acl_object_identity WHERE ID = 4;" + "DELETE FROM acl_object_identity WHERE ID = 3;" + + "DELETE FROM acl_object_identity WHERE ID = 2;" + "DELETE FROM acl_object_identity WHERE ID = 1;" + + "DELETE FROM acl_class;" + "DELETE FROM acl_sid;"; + jdbcTemplate.execute(query); + } + + private Ehcache getCache() { + Ehcache cache = cacheManager.getCache("basiclookuptestcache"); + cache.removeAll(); + return cache; + } + + @Test + public void testAclsRetrievalWithDefaultBatchSize() throws Exception { + ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); + ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(101)); + // Deliberately use an integer for the child, to reproduce bug report in SEC-819 + ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(102)); + + Map map = this.strategy.readAclsById(Arrays.asList(topParentOid, middleParentOid, childOid), null); + checkEntries(topParentOid, middleParentOid, childOid, map); + } + + @Test + public void testAclsRetrievalFromCacheOnly() throws Exception { + ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(100)); + ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(101)); + ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(102)); + + // Objects were put in cache + strategy.readAclsById(Arrays.asList(topParentOid, middleParentOid, childOid), null); + + // Let's empty the database to force acls retrieval from cache + emptyDatabase(); + Map map = this.strategy.readAclsById(Arrays.asList(topParentOid, middleParentOid, childOid), null); + + checkEntries(topParentOid, middleParentOid, childOid, map); + } + + @Test + public void testAclsRetrievalWithCustomBatchSize() throws Exception { + ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); + ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(101)); + ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(102)); + + // Set a batch size to allow multiple database queries in order to retrieve all acls + ((BasicLookupStrategy) this.strategy).setBatchSize(1); + Map map = this.strategy.readAclsById(Arrays.asList(topParentOid, middleParentOid, childOid), null); + checkEntries(topParentOid, middleParentOid, childOid, map); + } + + private void checkEntries(ObjectIdentity topParentOid, ObjectIdentity middleParentOid, ObjectIdentity childOid, + Map map) throws Exception { + Assert.assertEquals(3, map.size()); + + MutableAcl topParent = (MutableAcl) map.get(topParentOid); + MutableAcl middleParent = (MutableAcl) map.get(middleParentOid); + MutableAcl child = (MutableAcl) map.get(childOid); + + // Check the retrieved versions has IDs + Assert.assertNotNull(topParent.getId()); + Assert.assertNotNull(middleParent.getId()); + Assert.assertNotNull(child.getId()); + + // Check their parents were correctly retrieved + Assert.assertNull(topParent.getParentAcl()); + Assert.assertEquals(topParentOid, middleParent.getParentAcl().getObjectIdentity()); + Assert.assertEquals(middleParentOid, child.getParentAcl().getObjectIdentity()); + + // Check their ACEs were correctly retrieved + Assert.assertEquals(2, topParent.getEntries().size()); + Assert.assertEquals(1, middleParent.getEntries().size()); + Assert.assertEquals(1, child.getEntries().size()); + + // Check object identities were correctly retrieved + Assert.assertEquals(topParentOid, topParent.getObjectIdentity()); + Assert.assertEquals(middleParentOid, middleParent.getObjectIdentity()); + Assert.assertEquals(childOid, child.getObjectIdentity()); + + // Check each entry + Assert.assertTrue(topParent.isEntriesInheriting()); + Assert.assertEquals(topParent.getId(), new Long(1)); + Assert.assertEquals(topParent.getOwner(), new PrincipalSid("ben")); + Assert.assertEquals(topParent.getEntries().get(0).getId(), new Long(1)); + Assert.assertEquals(topParent.getEntries().get(0).getPermission(), BasePermission.READ); + Assert.assertEquals(topParent.getEntries().get(0).getSid(), new PrincipalSid("ben")); + Assert.assertFalse(((AuditableAccessControlEntry) topParent.getEntries().get(0)).isAuditFailure()); + Assert.assertFalse(((AuditableAccessControlEntry) topParent.getEntries().get(0)).isAuditSuccess()); + Assert.assertTrue(((AuditableAccessControlEntry) topParent.getEntries().get(0)).isGranting()); + + Assert.assertEquals(topParent.getEntries().get(1).getId(), new Long(2)); + Assert.assertEquals(topParent.getEntries().get(1).getPermission(), BasePermission.WRITE); + Assert.assertEquals(topParent.getEntries().get(1).getSid(), new PrincipalSid("ben")); + Assert.assertFalse(((AuditableAccessControlEntry) topParent.getEntries().get(1)).isAuditFailure()); + Assert.assertFalse(((AuditableAccessControlEntry) topParent.getEntries().get(1)).isAuditSuccess()); + Assert.assertFalse(((AuditableAccessControlEntry) topParent.getEntries().get(1)).isGranting()); + + Assert.assertTrue(middleParent.isEntriesInheriting()); + Assert.assertEquals(middleParent.getId(), new Long(2)); + Assert.assertEquals(middleParent.getOwner(), new PrincipalSid("ben")); + Assert.assertEquals(middleParent.getEntries().get(0).getId(), new Long(3)); + Assert.assertEquals(middleParent.getEntries().get(0).getPermission(), BasePermission.DELETE); + Assert.assertEquals(middleParent.getEntries().get(0).getSid(), new PrincipalSid("ben")); + Assert.assertFalse(((AuditableAccessControlEntry) middleParent.getEntries().get(0)).isAuditFailure()); + Assert.assertFalse(((AuditableAccessControlEntry) middleParent.getEntries().get(0)).isAuditSuccess()); + Assert.assertTrue(((AuditableAccessControlEntry) middleParent.getEntries().get(0)).isGranting()); + + Assert.assertTrue(child.isEntriesInheriting()); + Assert.assertEquals(child.getId(), new Long(3)); + Assert.assertEquals(child.getOwner(), new PrincipalSid("ben")); + Assert.assertEquals(child.getEntries().get(0).getId(), new Long(4)); + Assert.assertEquals(child.getEntries().get(0).getPermission(), BasePermission.DELETE); + Assert.assertEquals(child.getEntries().get(0).getSid(), new PrincipalSid("ben")); + Assert.assertFalse(((AuditableAccessControlEntry) child.getEntries().get(0)).isAuditFailure()); + Assert.assertFalse(((AuditableAccessControlEntry) child.getEntries().get(0)).isAuditSuccess()); + Assert.assertFalse((child.getEntries().get(0)).isGranting()); + } + + @Test + public void testAllParentsAreRetrievedWhenChildIsLoaded() throws Exception { + String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (4,2,103,1,1,1);"; + jdbcTemplate.execute(query); + + ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); + ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(101)); + ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(102)); + ObjectIdentity middleParent2Oid = new ObjectIdentityImpl(TARGET_CLASS, new Long(103)); + + // Retrieve the child + Map map = this.strategy.readAclsById(Arrays.asList(childOid), null); + + // Check that the child and all its parents were retrieved + Assert.assertNotNull(map.get(childOid)); + Assert.assertEquals(childOid, ((Acl) map.get(childOid)).getObjectIdentity()); + Assert.assertNotNull(map.get(middleParentOid)); + Assert.assertEquals(middleParentOid, ((Acl) map.get(middleParentOid)).getObjectIdentity()); + Assert.assertNotNull(map.get(topParentOid)); + Assert.assertEquals(topParentOid, ((Acl) map.get(topParentOid)).getObjectIdentity()); + + // The second parent shouldn't have been retrieved + Assert.assertNull(map.get(middleParent2Oid)); + } + + /** + * Test created from SEC-590. + */ + @Test + public void testReadAllObjectIdentitiesWhenLastElementIsAlreadyCached() throws Exception { + String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (4,2,104,null,1,1);" + + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (5,2,105,4,1,1);" + + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (6,2,106,4,1,1);" + + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (7,2,107,5,1,1);" + + "INSERT INTO acl_entry(ID,ACL_OBJECT_IDENTITY,ACE_ORDER,SID,MASK,GRANTING,AUDIT_SUCCESS,AUDIT_FAILURE) VALUES (5,4,0,1,1,1,0,0)"; + jdbcTemplate.execute(query); + + ObjectIdentity grandParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(104)); + ObjectIdentity parent1Oid = new ObjectIdentityImpl(TARGET_CLASS, new Long(105)); + ObjectIdentity parent2Oid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(106)); + ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(107)); + + // First lookup only child, thus populating the cache with grandParent, parent1 and child + List checkPermission = Arrays.asList(BasePermission.READ); + List sids = Arrays.asList(BEN_SID); + List childOids = Arrays.asList(childOid); + + strategy.setBatchSize(6); + Map foundAcls = strategy.readAclsById(childOids, sids); + + Acl foundChildAcl = (Acl) foundAcls.get(childOid); + Assert.assertNotNull(foundChildAcl); + Assert.assertTrue(foundChildAcl.isGranted(checkPermission, sids, false)); + + // Search for object identities has to be done in the following order: last element have to be one which + // is already in cache and the element before it must not be stored in cache + List allOids = Arrays.asList(grandParentOid, parent1Oid, parent2Oid, childOid); + try { + foundAcls = strategy.readAclsById(allOids, sids); + Assert.assertTrue(true); + } catch (NotFoundException notExpected) { + Assert.fail("It shouldn't have thrown NotFoundException"); + } + + Acl foundParent2Acl = (Acl) foundAcls.get(parent2Oid); + Assert.assertNotNull(foundParent2Acl); + Assert.assertTrue(foundParent2Acl.isGranted(checkPermission, sids, false)); + } + + @Test(expected=IllegalArgumentException.class) + public void nullOwnerIsNotSupported() { + String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (4,2,104,null,null,1);"; + + jdbcTemplate.execute(query); + + ObjectIdentity oid = new ObjectIdentityImpl(TARGET_CLASS, new Long(104)); + + strategy.readAclsById(Arrays.asList(oid), Arrays.asList(BEN_SID)); + } + +} diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/DatabaseSeeder.java b/acl/src/test/java/org/springframework/security/acls/jdbc/DatabaseSeeder.java index f261d6bd64..058aee7be9 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/DatabaseSeeder.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/DatabaseSeeder.java @@ -30,7 +30,6 @@ import javax.sql.DataSource; * Seeds the database for {@link JdbcMutableAclServiceTests}. * * @author Ben Alex - * @version $Id$ */ public class DatabaseSeeder { //~ Constructors =================================================================================================== diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/EhCacheBasedAclCacheTests.java b/acl/src/test/java/org/springframework/security/acls/jdbc/EhCacheBasedAclCacheTests.java index 33518843a5..16184217ca 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/EhCacheBasedAclCacheTests.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/EhCacheBasedAclCacheTests.java @@ -1,267 +1,266 @@ -package org.springframework.security.acls.jdbc; - -import static org.junit.Assert.*; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.util.Map; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.springframework.security.acls.domain.AclAuthorizationStrategy; -import org.springframework.security.acls.domain.AclAuthorizationStrategyImpl; -import org.springframework.security.acls.domain.AclImpl; -import org.springframework.security.acls.domain.ConsoleAuditLogger; -import org.springframework.security.acls.domain.EhCacheBasedAclCache; -import org.springframework.security.acls.domain.ObjectIdentityImpl; -import org.springframework.security.acls.model.MutableAcl; -import org.springframework.security.acls.model.ObjectIdentity; -import org.springframework.security.authentication.TestingAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthorityImpl; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.util.FieldUtils; - -/** - * Tests {@link EhCacheBasedAclCache} - * - * @author Andrei Stefan - * @version $Id$ - */ -public class EhCacheBasedAclCacheTests { - private static final String TARGET_CLASS = "org.springframework.security.acls.TargetObject"; - - private static CacheManager cacheManager; - - @BeforeClass - public static void initCacheManaer() { - cacheManager = new CacheManager(); - // Use disk caching immediately (to test for serialization issue reported in SEC-527) - cacheManager.addCache(new Cache("ehcachebasedacltests", 0, true, false, 600, 300)); - } - - @AfterClass - public static void shutdownCacheManager() { - cacheManager.removalAll(); - cacheManager.shutdown(); - } - - @After - public void clearContext() { - SecurityContextHolder.clearContext(); - } - - private Ehcache getCache() { - Ehcache cache = cacheManager.getCache("ehcachebasedacltests"); - cache.removeAll(); - - return cache; - } - - @Test(expected=IllegalArgumentException.class) - public void constructorRejectsNullParameters() throws Exception { - new EhCacheBasedAclCache(null); - } - - @Test - public void methodsRejectNullParameters() throws Exception { - Ehcache cache = new MockEhcache(); - EhCacheBasedAclCache myCache = new EhCacheBasedAclCache(cache); - - try { - Serializable id = null; - myCache.evictFromCache(id); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - assertTrue(true); - } - - try { - ObjectIdentity obj = null; - myCache.evictFromCache(obj); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - assertTrue(true); - } - - try { - Serializable id = null; - myCache.getFromCache(id); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - assertTrue(true); - } - - try { - ObjectIdentity obj = null; - myCache.getFromCache(obj); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - assertTrue(true); - } - - try { - MutableAcl acl = null; - myCache.putInCache(acl); - fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - assertTrue(true); - } - } - - // SEC-527 - @Test - public void testDiskSerializationOfMutableAclObjectInstance() throws Exception { - ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); - AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), - new GrantedAuthorityImpl("ROLE_GENERAL") }); - MutableAcl acl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); - - // Serialization test - File file = File.createTempFile("SEC_TEST", ".object"); - FileOutputStream fos = new FileOutputStream(file); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(acl); - oos.close(); - - FileInputStream fis = new FileInputStream(file); - ObjectInputStream ois = new ObjectInputStream(fis); - MutableAcl retrieved = (MutableAcl) ois.readObject(); - ois.close(); - - assertEquals(acl, retrieved); - - Object retrieved1 = FieldUtils.getProtectedFieldValue("aclAuthorizationStrategy", retrieved); - assertEquals(null, retrieved1); - - Object retrieved2 = FieldUtils.getProtectedFieldValue("auditLogger", retrieved); - assertEquals(null, retrieved2); - } - - @Test - public void cacheOperationsAclWithoutParent() throws Exception { - Ehcache cache = getCache(); - EhCacheBasedAclCache myCache = new EhCacheBasedAclCache(cache); - - ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); - AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), - new GrantedAuthorityImpl("ROLE_GENERAL") }); - MutableAcl acl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); - - assertEquals(0, cache.getDiskStoreSize()); - myCache.putInCache(acl); - assertEquals(cache.getSize(), 2); - assertEquals(2, cache.getDiskStoreSize()); - assertTrue(cache.isElementOnDisk(acl.getObjectIdentity())); - assertFalse(cache.isElementInMemory(acl.getObjectIdentity())); - - // Check we can get from cache the same objects we put in - assertEquals(myCache.getFromCache(new Long(1)), acl); - assertEquals(myCache.getFromCache(identity), acl); - - // Put another object in cache - ObjectIdentity identity2 = new ObjectIdentityImpl(TARGET_CLASS, new Long(101)); - MutableAcl acl2 = new AclImpl(identity2, new Long(2), aclAuthorizationStrategy, new ConsoleAuditLogger()); - - myCache.putInCache(acl2); - assertEquals(cache.getSize(), 4); - assertEquals(4, cache.getDiskStoreSize()); - - // Try to evict an entry that doesn't exist - myCache.evictFromCache(new Long(3)); - myCache.evictFromCache(new ObjectIdentityImpl(TARGET_CLASS, new Long(102))); - assertEquals(cache.getSize(), 4); - assertEquals(4, cache.getDiskStoreSize()); - - myCache.evictFromCache(new Long(1)); - assertEquals(cache.getSize(), 2); - assertEquals(2, cache.getDiskStoreSize()); - - // Check the second object inserted - assertEquals(myCache.getFromCache(new Long(2)), acl2); - assertEquals(myCache.getFromCache(identity2), acl2); - - myCache.evictFromCache(identity2); - assertEquals(cache.getSize(), 0); - } - - @SuppressWarnings("unchecked") - @Test - public void cacheOperationsAclWithParent() throws Exception { - Ehcache cache = getCache(); - EhCacheBasedAclCache myCache = new EhCacheBasedAclCache(cache); - - Authentication auth = new TestingAuthenticationToken("user", "password", new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_GENERAL") }); - auth.setAuthenticated(true); - SecurityContextHolder.getContext().setAuthentication(auth); - - ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(1)); - ObjectIdentity identityParent = new ObjectIdentityImpl(TARGET_CLASS, new Long(2)); - AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { - new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), - new GrantedAuthorityImpl("ROLE_GENERAL") }); - MutableAcl acl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); - MutableAcl parentAcl = new AclImpl(identityParent, new Long(2), aclAuthorizationStrategy, new ConsoleAuditLogger()); - - acl.setParent(parentAcl); - - assertEquals(0, cache.getDiskStoreSize()); - myCache.putInCache(acl); - assertEquals(cache.getSize(), 4); - assertEquals(4, cache.getDiskStoreSize()); - assertTrue(cache.isElementOnDisk(acl.getObjectIdentity())); - assertTrue(cache.isElementOnDisk(Long.valueOf(1))); - assertFalse(cache.isElementInMemory(acl.getObjectIdentity())); - assertFalse(cache.isElementInMemory(Long.valueOf(1))); - cache.flush(); - // Wait for the spool to be written to disk (it's asynchronous) - Map spool = (Map) FieldUtils.getFieldValue(cache, "diskStore.spool"); - - while(spool.size() > 0) { - Thread.sleep(50); - } - - // Check we can get from cache the same objects we put in - AclImpl aclFromCache = (AclImpl) myCache.getFromCache(new Long(1)); - // For the checks on transient fields, we need to be sure that the object is being loaded from the cache, - // not from the ehcache spool or elsewhere... - assertFalse(acl == aclFromCache); - assertEquals(acl, aclFromCache); - // SEC-951 check transient fields are set on parent - assertNotNull(FieldUtils.getFieldValue(aclFromCache.getParentAcl(), "aclAuthorizationStrategy")); - assertNotNull(FieldUtils.getFieldValue(aclFromCache.getParentAcl(), "auditLogger")); - assertEquals(acl, myCache.getFromCache(identity)); - assertNotNull(FieldUtils.getFieldValue(aclFromCache, "aclAuthorizationStrategy")); - AclImpl parentAclFromCache = (AclImpl) myCache.getFromCache(new Long(2)); - assertEquals(parentAcl, parentAclFromCache); - assertNotNull(FieldUtils.getFieldValue(parentAclFromCache, "aclAuthorizationStrategy")); - assertEquals(parentAcl, myCache.getFromCache(identityParent)); - } - - //~ Inner Classes ================================================================================================== - - private class MockEhcache extends Cache { - public MockEhcache() { - super("cache", 0, true, true, 0, 0); - } - } -} +package org.springframework.security.acls.jdbc; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Map; + +import net.sf.ehcache.Cache; +import net.sf.ehcache.CacheManager; +import net.sf.ehcache.Ehcache; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.security.acls.domain.AclAuthorizationStrategy; +import org.springframework.security.acls.domain.AclAuthorizationStrategyImpl; +import org.springframework.security.acls.domain.AclImpl; +import org.springframework.security.acls.domain.ConsoleAuditLogger; +import org.springframework.security.acls.domain.EhCacheBasedAclCache; +import org.springframework.security.acls.domain.ObjectIdentityImpl; +import org.springframework.security.acls.model.MutableAcl; +import org.springframework.security.acls.model.ObjectIdentity; +import org.springframework.security.authentication.TestingAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.GrantedAuthorityImpl; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.util.FieldUtils; + +/** + * Tests {@link EhCacheBasedAclCache} + * + * @author Andrei Stefan + */ +public class EhCacheBasedAclCacheTests { + private static final String TARGET_CLASS = "org.springframework.security.acls.TargetObject"; + + private static CacheManager cacheManager; + + @BeforeClass + public static void initCacheManaer() { + cacheManager = new CacheManager(); + // Use disk caching immediately (to test for serialization issue reported in SEC-527) + cacheManager.addCache(new Cache("ehcachebasedacltests", 0, true, false, 600, 300)); + } + + @AfterClass + public static void shutdownCacheManager() { + cacheManager.removalAll(); + cacheManager.shutdown(); + } + + @After + public void clearContext() { + SecurityContextHolder.clearContext(); + } + + private Ehcache getCache() { + Ehcache cache = cacheManager.getCache("ehcachebasedacltests"); + cache.removeAll(); + + return cache; + } + + @Test(expected=IllegalArgumentException.class) + public void constructorRejectsNullParameters() throws Exception { + new EhCacheBasedAclCache(null); + } + + @Test + public void methodsRejectNullParameters() throws Exception { + Ehcache cache = new MockEhcache(); + EhCacheBasedAclCache myCache = new EhCacheBasedAclCache(cache); + + try { + Serializable id = null; + myCache.evictFromCache(id); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + assertTrue(true); + } + + try { + ObjectIdentity obj = null; + myCache.evictFromCache(obj); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + assertTrue(true); + } + + try { + Serializable id = null; + myCache.getFromCache(id); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + assertTrue(true); + } + + try { + ObjectIdentity obj = null; + myCache.getFromCache(obj); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + assertTrue(true); + } + + try { + MutableAcl acl = null; + myCache.putInCache(acl); + fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + assertTrue(true); + } + } + + // SEC-527 + @Test + public void testDiskSerializationOfMutableAclObjectInstance() throws Exception { + ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); + AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), + new GrantedAuthorityImpl("ROLE_GENERAL") }); + MutableAcl acl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); + + // Serialization test + File file = File.createTempFile("SEC_TEST", ".object"); + FileOutputStream fos = new FileOutputStream(file); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(acl); + oos.close(); + + FileInputStream fis = new FileInputStream(file); + ObjectInputStream ois = new ObjectInputStream(fis); + MutableAcl retrieved = (MutableAcl) ois.readObject(); + ois.close(); + + assertEquals(acl, retrieved); + + Object retrieved1 = FieldUtils.getProtectedFieldValue("aclAuthorizationStrategy", retrieved); + assertEquals(null, retrieved1); + + Object retrieved2 = FieldUtils.getProtectedFieldValue("auditLogger", retrieved); + assertEquals(null, retrieved2); + } + + @Test + public void cacheOperationsAclWithoutParent() throws Exception { + Ehcache cache = getCache(); + EhCacheBasedAclCache myCache = new EhCacheBasedAclCache(cache); + + ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); + AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), + new GrantedAuthorityImpl("ROLE_GENERAL") }); + MutableAcl acl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); + + assertEquals(0, cache.getDiskStoreSize()); + myCache.putInCache(acl); + assertEquals(cache.getSize(), 2); + assertEquals(2, cache.getDiskStoreSize()); + assertTrue(cache.isElementOnDisk(acl.getObjectIdentity())); + assertFalse(cache.isElementInMemory(acl.getObjectIdentity())); + + // Check we can get from cache the same objects we put in + assertEquals(myCache.getFromCache(new Long(1)), acl); + assertEquals(myCache.getFromCache(identity), acl); + + // Put another object in cache + ObjectIdentity identity2 = new ObjectIdentityImpl(TARGET_CLASS, new Long(101)); + MutableAcl acl2 = new AclImpl(identity2, new Long(2), aclAuthorizationStrategy, new ConsoleAuditLogger()); + + myCache.putInCache(acl2); + assertEquals(cache.getSize(), 4); + assertEquals(4, cache.getDiskStoreSize()); + + // Try to evict an entry that doesn't exist + myCache.evictFromCache(new Long(3)); + myCache.evictFromCache(new ObjectIdentityImpl(TARGET_CLASS, new Long(102))); + assertEquals(cache.getSize(), 4); + assertEquals(4, cache.getDiskStoreSize()); + + myCache.evictFromCache(new Long(1)); + assertEquals(cache.getSize(), 2); + assertEquals(2, cache.getDiskStoreSize()); + + // Check the second object inserted + assertEquals(myCache.getFromCache(new Long(2)), acl2); + assertEquals(myCache.getFromCache(identity2), acl2); + + myCache.evictFromCache(identity2); + assertEquals(cache.getSize(), 0); + } + + @SuppressWarnings("unchecked") + @Test + public void cacheOperationsAclWithParent() throws Exception { + Ehcache cache = getCache(); + EhCacheBasedAclCache myCache = new EhCacheBasedAclCache(cache); + + Authentication auth = new TestingAuthenticationToken("user", "password", new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_GENERAL") }); + auth.setAuthenticated(true); + SecurityContextHolder.getContext().setAuthentication(auth); + + ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(1)); + ObjectIdentity identityParent = new ObjectIdentityImpl(TARGET_CLASS, new Long(2)); + AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(new GrantedAuthority[] { + new GrantedAuthorityImpl("ROLE_OWNERSHIP"), new GrantedAuthorityImpl("ROLE_AUDITING"), + new GrantedAuthorityImpl("ROLE_GENERAL") }); + MutableAcl acl = new AclImpl(identity, new Long(1), aclAuthorizationStrategy, new ConsoleAuditLogger()); + MutableAcl parentAcl = new AclImpl(identityParent, new Long(2), aclAuthorizationStrategy, new ConsoleAuditLogger()); + + acl.setParent(parentAcl); + + assertEquals(0, cache.getDiskStoreSize()); + myCache.putInCache(acl); + assertEquals(cache.getSize(), 4); + assertEquals(4, cache.getDiskStoreSize()); + assertTrue(cache.isElementOnDisk(acl.getObjectIdentity())); + assertTrue(cache.isElementOnDisk(Long.valueOf(1))); + assertFalse(cache.isElementInMemory(acl.getObjectIdentity())); + assertFalse(cache.isElementInMemory(Long.valueOf(1))); + cache.flush(); + // Wait for the spool to be written to disk (it's asynchronous) + Map spool = (Map) FieldUtils.getFieldValue(cache, "diskStore.spool"); + + while(spool.size() > 0) { + Thread.sleep(50); + } + + // Check we can get from cache the same objects we put in + AclImpl aclFromCache = (AclImpl) myCache.getFromCache(new Long(1)); + // For the checks on transient fields, we need to be sure that the object is being loaded from the cache, + // not from the ehcache spool or elsewhere... + assertFalse(acl == aclFromCache); + assertEquals(acl, aclFromCache); + // SEC-951 check transient fields are set on parent + assertNotNull(FieldUtils.getFieldValue(aclFromCache.getParentAcl(), "aclAuthorizationStrategy")); + assertNotNull(FieldUtils.getFieldValue(aclFromCache.getParentAcl(), "auditLogger")); + assertEquals(acl, myCache.getFromCache(identity)); + assertNotNull(FieldUtils.getFieldValue(aclFromCache, "aclAuthorizationStrategy")); + AclImpl parentAclFromCache = (AclImpl) myCache.getFromCache(new Long(2)); + assertEquals(parentAcl, parentAclFromCache); + assertNotNull(FieldUtils.getFieldValue(parentAclFromCache, "aclAuthorizationStrategy")); + assertEquals(parentAcl, myCache.getFromCache(identityParent)); + } + + //~ Inner Classes ================================================================================================== + + private class MockEhcache extends Cache { + public MockEhcache() { + super("cache", 0, true, true, 0, 0); + } + } +} diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTests.java b/acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTests.java index 8e9776b5b6..7b0a906687 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTests.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTests.java @@ -57,7 +57,6 @@ import org.springframework.transaction.annotation.Transactional; * * @author Ben Alex * @author Andrei Stefan - * @version $Id:JdbcMutableAclServiceTests.java 1754 2006-11-17 02:01:21Z benalex $ */ @ContextConfiguration(locations={"/jdbcMutableAclServiceTests-context.xml"}) public class JdbcMutableAclServiceTests extends AbstractTransactionalJUnit4SpringContextTests { diff --git a/acl/src/test/java/org/springframework/security/acls/sid/SidRetrievalStrategyTests.java b/acl/src/test/java/org/springframework/security/acls/sid/SidRetrievalStrategyTests.java index 882cc1a1d4..0dae7784f5 100644 --- a/acl/src/test/java/org/springframework/security/acls/sid/SidRetrievalStrategyTests.java +++ b/acl/src/test/java/org/springframework/security/acls/sid/SidRetrievalStrategyTests.java @@ -1,66 +1,66 @@ -package org.springframework.security.acls.sid; - -import static org.junit.Assert.*; -import static org.mockito.Matchers.*; -import static org.mockito.Mockito.*; - -import java.util.List; - -import org.junit.Test; -import org.springframework.security.access.hierarchicalroles.RoleHierarchy; -import org.springframework.security.acls.domain.GrantedAuthoritySid; -import org.springframework.security.acls.domain.PrincipalSid; -import org.springframework.security.acls.domain.SidRetrievalStrategyImpl; -import org.springframework.security.acls.model.Sid; -import org.springframework.security.acls.model.SidRetrievalStrategy; -import org.springframework.security.authentication.TestingAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.AuthorityUtils; - -/** - * Tests for {@link SidRetrievalStrategyImpl} - * - * @author Andrei Stefan - * @author Luke Taylor - */ -@SuppressWarnings("unchecked") -public class SidRetrievalStrategyTests { - Authentication authentication = new TestingAuthenticationToken("scott", "password", "A", "B", "C"); - - //~ Methods ======================================================================================================== - - @Test - public void correctSidsAreRetrieved() throws Exception { - SidRetrievalStrategy retrStrategy = new SidRetrievalStrategyImpl(); - List sids = retrStrategy.getSids(authentication); - - assertNotNull(sids); - assertEquals(4, sids.size()); - assertNotNull(sids.get(0)); - assertTrue(sids.get(0) instanceof PrincipalSid); - - for (int i = 1; i < sids.size(); i++) { - assertTrue(sids.get(i) instanceof GrantedAuthoritySid); - } - - assertEquals("scott", ((PrincipalSid) sids.get(0)).getPrincipal()); - assertEquals("A", ((GrantedAuthoritySid) sids.get(1)).getGrantedAuthority()); - assertEquals("B", ((GrantedAuthoritySid) sids.get(2)).getGrantedAuthority()); - assertEquals("C", ((GrantedAuthoritySid) sids.get(3)).getGrantedAuthority()); - } - - @Test - public void roleHierarchyIsUsedWhenSet() throws Exception { - RoleHierarchy rh = mock(RoleHierarchy.class); - List rhAuthorities = AuthorityUtils.createAuthorityList("D"); - when(rh.getReachableGrantedAuthorities(anyList())).thenReturn(rhAuthorities); - SidRetrievalStrategy strat = new SidRetrievalStrategyImpl(rh); - - List sids = strat.getSids(authentication); - assertEquals(2, sids.size()); - assertNotNull(sids.get(0)); - assertTrue(sids.get(0) instanceof PrincipalSid); - assertEquals("D", ((GrantedAuthoritySid) sids.get(1)).getGrantedAuthority()); - } -} +package org.springframework.security.acls.sid; + +import static org.junit.Assert.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import java.util.List; + +import org.junit.Test; +import org.springframework.security.access.hierarchicalroles.RoleHierarchy; +import org.springframework.security.acls.domain.GrantedAuthoritySid; +import org.springframework.security.acls.domain.PrincipalSid; +import org.springframework.security.acls.domain.SidRetrievalStrategyImpl; +import org.springframework.security.acls.model.Sid; +import org.springframework.security.acls.model.SidRetrievalStrategy; +import org.springframework.security.authentication.TestingAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; + +/** + * Tests for {@link SidRetrievalStrategyImpl} + * + * @author Andrei Stefan + * @author Luke Taylor + */ +@SuppressWarnings("unchecked") +public class SidRetrievalStrategyTests { + Authentication authentication = new TestingAuthenticationToken("scott", "password", "A", "B", "C"); + + //~ Methods ======================================================================================================== + + @Test + public void correctSidsAreRetrieved() throws Exception { + SidRetrievalStrategy retrStrategy = new SidRetrievalStrategyImpl(); + List sids = retrStrategy.getSids(authentication); + + assertNotNull(sids); + assertEquals(4, sids.size()); + assertNotNull(sids.get(0)); + assertTrue(sids.get(0) instanceof PrincipalSid); + + for (int i = 1; i < sids.size(); i++) { + assertTrue(sids.get(i) instanceof GrantedAuthoritySid); + } + + assertEquals("scott", ((PrincipalSid) sids.get(0)).getPrincipal()); + assertEquals("A", ((GrantedAuthoritySid) sids.get(1)).getGrantedAuthority()); + assertEquals("B", ((GrantedAuthoritySid) sids.get(2)).getGrantedAuthority()); + assertEquals("C", ((GrantedAuthoritySid) sids.get(3)).getGrantedAuthority()); + } + + @Test + public void roleHierarchyIsUsedWhenSet() throws Exception { + RoleHierarchy rh = mock(RoleHierarchy.class); + List rhAuthorities = AuthorityUtils.createAuthorityList("D"); + when(rh.getReachableGrantedAuthorities(anyList())).thenReturn(rhAuthorities); + SidRetrievalStrategy strat = new SidRetrievalStrategyImpl(rh); + + List sids = strat.getSids(authentication); + assertEquals(2, sids.size()); + assertNotNull(sids.get(0)); + assertTrue(sids.get(0) instanceof PrincipalSid); + assertEquals("D", ((GrantedAuthoritySid) sids.get(1)).getGrantedAuthority()); + } +} diff --git a/acl/src/test/java/org/springframework/security/acls/sid/SidTests.java b/acl/src/test/java/org/springframework/security/acls/sid/SidTests.java index d7e402c878..1f8bd6a84c 100644 --- a/acl/src/test/java/org/springframework/security/acls/sid/SidTests.java +++ b/acl/src/test/java/org/springframework/security/acls/sid/SidTests.java @@ -1,190 +1,190 @@ -package org.springframework.security.acls.sid; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.springframework.security.acls.domain.GrantedAuthoritySid; -import org.springframework.security.acls.domain.PrincipalSid; -import org.springframework.security.acls.model.Sid; -import org.springframework.security.authentication.TestingAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthorityImpl; - -public class SidTests extends TestCase { - - //~ Methods ======================================================================================================== - - public void testPrincipalSidConstructorsRequiredFields() throws Exception { - // Check one String-argument constructor - try { - String string = null; - new PrincipalSid(string); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - new PrincipalSid(""); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - new PrincipalSid("johndoe"); - Assert.assertTrue(true); - } - catch (IllegalArgumentException notExpected) { - Assert.fail("It shouldn't have thrown IllegalArgumentException"); - } - - // Check one Authentication-argument constructor - try { - Authentication authentication = null; - new PrincipalSid(authentication); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - Authentication authentication = new TestingAuthenticationToken(null, "password"); - new PrincipalSid(authentication); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); - new PrincipalSid(authentication); - Assert.assertTrue(true); - } - catch (IllegalArgumentException notExpected) { - Assert.fail("It shouldn't have thrown IllegalArgumentException"); - } - } - - public void testGrantedAuthoritySidConstructorsRequiredFields() throws Exception { - // Check one String-argument constructor - try { - String string = null; - new GrantedAuthoritySid(string); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - new GrantedAuthoritySid(""); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - new GrantedAuthoritySid("ROLE_TEST"); - Assert.assertTrue(true); - } - catch (IllegalArgumentException notExpected) { - Assert.fail("It shouldn't have thrown IllegalArgumentException"); - } - - // Check one GrantedAuthority-argument constructor - try { - GrantedAuthority ga = null; - new GrantedAuthoritySid(ga); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - GrantedAuthority ga = new GrantedAuthorityImpl(null); - new GrantedAuthoritySid(ga); - Assert.fail("It should have thrown IllegalArgumentException"); - } - catch (IllegalArgumentException expected) { - Assert.assertTrue(true); - } - - try { - GrantedAuthority ga = new GrantedAuthorityImpl("ROLE_TEST"); - new GrantedAuthoritySid(ga); - Assert.assertTrue(true); - } - catch (IllegalArgumentException notExpected) { - Assert.fail("It shouldn't have thrown IllegalArgumentException"); - } - } - - public void testPrincipalSidEquals() throws Exception { - Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); - Sid principalSid = new PrincipalSid(authentication); - - Assert.assertFalse(principalSid.equals(null)); - Assert.assertFalse(principalSid.equals("DIFFERENT_TYPE_OBJECT")); - Assert.assertTrue(principalSid.equals(principalSid)); - Assert.assertTrue(principalSid.equals(new PrincipalSid(authentication))); - Assert.assertTrue(principalSid.equals(new PrincipalSid(new TestingAuthenticationToken("johndoe", null)))); - Assert.assertFalse(principalSid.equals(new PrincipalSid(new TestingAuthenticationToken("scott", null)))); - Assert.assertTrue(principalSid.equals(new PrincipalSid("johndoe"))); - Assert.assertFalse(principalSid.equals(new PrincipalSid("scott"))); - } - - public void testGrantedAuthoritySidEquals() throws Exception { - GrantedAuthority ga = new GrantedAuthorityImpl("ROLE_TEST"); - Sid gaSid = new GrantedAuthoritySid(ga); - - Assert.assertFalse(gaSid.equals(null)); - Assert.assertFalse(gaSid.equals("DIFFERENT_TYPE_OBJECT")); - Assert.assertTrue(gaSid.equals(gaSid)); - Assert.assertTrue(gaSid.equals(new GrantedAuthoritySid(ga))); - Assert.assertTrue(gaSid.equals(new GrantedAuthoritySid(new GrantedAuthorityImpl("ROLE_TEST")))); - Assert.assertFalse(gaSid.equals(new GrantedAuthoritySid(new GrantedAuthorityImpl("ROLE_NOT_EQUAL")))); - Assert.assertTrue(gaSid.equals(new GrantedAuthoritySid("ROLE_TEST"))); - Assert.assertFalse(gaSid.equals(new GrantedAuthoritySid("ROLE_NOT_EQUAL"))); - } - - public void testPrincipalSidHashCode() throws Exception { - Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); - Sid principalSid = new PrincipalSid(authentication); - - Assert.assertTrue(principalSid.hashCode() == new String("johndoe").hashCode()); - Assert.assertTrue(principalSid.hashCode() == new PrincipalSid("johndoe").hashCode()); - Assert.assertTrue(principalSid.hashCode() != new PrincipalSid("scott").hashCode()); - Assert.assertTrue(principalSid.hashCode() != new PrincipalSid(new TestingAuthenticationToken("scott", "password")).hashCode()); - } - - public void testGrantedAuthoritySidHashCode() throws Exception { - GrantedAuthority ga = new GrantedAuthorityImpl("ROLE_TEST"); - Sid gaSid = new GrantedAuthoritySid(ga); - - Assert.assertTrue(gaSid.hashCode() == new String("ROLE_TEST").hashCode()); - Assert.assertTrue(gaSid.hashCode() == new GrantedAuthoritySid("ROLE_TEST").hashCode()); - Assert.assertTrue(gaSid.hashCode() != new GrantedAuthoritySid("ROLE_TEST_2").hashCode()); - Assert.assertTrue(gaSid.hashCode() != new GrantedAuthoritySid(new GrantedAuthorityImpl("ROLE_TEST_2")).hashCode()); - } - - public void testGetters() throws Exception { - Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); - PrincipalSid principalSid = new PrincipalSid(authentication); - GrantedAuthority ga = new GrantedAuthorityImpl("ROLE_TEST"); - GrantedAuthoritySid gaSid = new GrantedAuthoritySid(ga); - - Assert.assertTrue("johndoe".equals(principalSid.getPrincipal())); - Assert.assertFalse("scott".equals(principalSid.getPrincipal())); - - Assert.assertTrue("ROLE_TEST".equals(gaSid.getGrantedAuthority())); - Assert.assertFalse("ROLE_TEST2".equals(gaSid.getGrantedAuthority())); - } -} +package org.springframework.security.acls.sid; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.springframework.security.acls.domain.GrantedAuthoritySid; +import org.springframework.security.acls.domain.PrincipalSid; +import org.springframework.security.acls.model.Sid; +import org.springframework.security.authentication.TestingAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.GrantedAuthorityImpl; + +public class SidTests extends TestCase { + + //~ Methods ======================================================================================================== + + public void testPrincipalSidConstructorsRequiredFields() throws Exception { + // Check one String-argument constructor + try { + String string = null; + new PrincipalSid(string); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + new PrincipalSid(""); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + new PrincipalSid("johndoe"); + Assert.assertTrue(true); + } + catch (IllegalArgumentException notExpected) { + Assert.fail("It shouldn't have thrown IllegalArgumentException"); + } + + // Check one Authentication-argument constructor + try { + Authentication authentication = null; + new PrincipalSid(authentication); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + Authentication authentication = new TestingAuthenticationToken(null, "password"); + new PrincipalSid(authentication); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); + new PrincipalSid(authentication); + Assert.assertTrue(true); + } + catch (IllegalArgumentException notExpected) { + Assert.fail("It shouldn't have thrown IllegalArgumentException"); + } + } + + public void testGrantedAuthoritySidConstructorsRequiredFields() throws Exception { + // Check one String-argument constructor + try { + String string = null; + new GrantedAuthoritySid(string); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + new GrantedAuthoritySid(""); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + new GrantedAuthoritySid("ROLE_TEST"); + Assert.assertTrue(true); + } + catch (IllegalArgumentException notExpected) { + Assert.fail("It shouldn't have thrown IllegalArgumentException"); + } + + // Check one GrantedAuthority-argument constructor + try { + GrantedAuthority ga = null; + new GrantedAuthoritySid(ga); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + GrantedAuthority ga = new GrantedAuthorityImpl(null); + new GrantedAuthoritySid(ga); + Assert.fail("It should have thrown IllegalArgumentException"); + } + catch (IllegalArgumentException expected) { + Assert.assertTrue(true); + } + + try { + GrantedAuthority ga = new GrantedAuthorityImpl("ROLE_TEST"); + new GrantedAuthoritySid(ga); + Assert.assertTrue(true); + } + catch (IllegalArgumentException notExpected) { + Assert.fail("It shouldn't have thrown IllegalArgumentException"); + } + } + + public void testPrincipalSidEquals() throws Exception { + Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); + Sid principalSid = new PrincipalSid(authentication); + + Assert.assertFalse(principalSid.equals(null)); + Assert.assertFalse(principalSid.equals("DIFFERENT_TYPE_OBJECT")); + Assert.assertTrue(principalSid.equals(principalSid)); + Assert.assertTrue(principalSid.equals(new PrincipalSid(authentication))); + Assert.assertTrue(principalSid.equals(new PrincipalSid(new TestingAuthenticationToken("johndoe", null)))); + Assert.assertFalse(principalSid.equals(new PrincipalSid(new TestingAuthenticationToken("scott", null)))); + Assert.assertTrue(principalSid.equals(new PrincipalSid("johndoe"))); + Assert.assertFalse(principalSid.equals(new PrincipalSid("scott"))); + } + + public void testGrantedAuthoritySidEquals() throws Exception { + GrantedAuthority ga = new GrantedAuthorityImpl("ROLE_TEST"); + Sid gaSid = new GrantedAuthoritySid(ga); + + Assert.assertFalse(gaSid.equals(null)); + Assert.assertFalse(gaSid.equals("DIFFERENT_TYPE_OBJECT")); + Assert.assertTrue(gaSid.equals(gaSid)); + Assert.assertTrue(gaSid.equals(new GrantedAuthoritySid(ga))); + Assert.assertTrue(gaSid.equals(new GrantedAuthoritySid(new GrantedAuthorityImpl("ROLE_TEST")))); + Assert.assertFalse(gaSid.equals(new GrantedAuthoritySid(new GrantedAuthorityImpl("ROLE_NOT_EQUAL")))); + Assert.assertTrue(gaSid.equals(new GrantedAuthoritySid("ROLE_TEST"))); + Assert.assertFalse(gaSid.equals(new GrantedAuthoritySid("ROLE_NOT_EQUAL"))); + } + + public void testPrincipalSidHashCode() throws Exception { + Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); + Sid principalSid = new PrincipalSid(authentication); + + Assert.assertTrue(principalSid.hashCode() == new String("johndoe").hashCode()); + Assert.assertTrue(principalSid.hashCode() == new PrincipalSid("johndoe").hashCode()); + Assert.assertTrue(principalSid.hashCode() != new PrincipalSid("scott").hashCode()); + Assert.assertTrue(principalSid.hashCode() != new PrincipalSid(new TestingAuthenticationToken("scott", "password")).hashCode()); + } + + public void testGrantedAuthoritySidHashCode() throws Exception { + GrantedAuthority ga = new GrantedAuthorityImpl("ROLE_TEST"); + Sid gaSid = new GrantedAuthoritySid(ga); + + Assert.assertTrue(gaSid.hashCode() == new String("ROLE_TEST").hashCode()); + Assert.assertTrue(gaSid.hashCode() == new GrantedAuthoritySid("ROLE_TEST").hashCode()); + Assert.assertTrue(gaSid.hashCode() != new GrantedAuthoritySid("ROLE_TEST_2").hashCode()); + Assert.assertTrue(gaSid.hashCode() != new GrantedAuthoritySid(new GrantedAuthorityImpl("ROLE_TEST_2")).hashCode()); + } + + public void testGetters() throws Exception { + Authentication authentication = new TestingAuthenticationToken("johndoe", "password"); + PrincipalSid principalSid = new PrincipalSid(authentication); + GrantedAuthority ga = new GrantedAuthorityImpl("ROLE_TEST"); + GrantedAuthoritySid gaSid = new GrantedAuthoritySid(ga); + + Assert.assertTrue("johndoe".equals(principalSid.getPrincipal())); + Assert.assertFalse("scott".equals(principalSid.getPrincipal())); + + Assert.assertTrue("ROLE_TEST".equals(gaSid.getGrantedAuthority())); + Assert.assertFalse("ROLE_TEST2".equals(gaSid.getGrantedAuthority())); + } +} diff --git a/acl/src/test/resources/jdbcMutableAclServiceTests-context.xml b/acl/src/test/resources/jdbcMutableAclServiceTests-context.xml index e3090331a8..ef0d8750ad 100644 --- a/acl/src/test/resources/jdbcMutableAclServiceTests-context.xml +++ b/acl/src/test/resources/jdbcMutableAclServiceTests-context.xml @@ -1,84 +1,83 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cas/src/main/java/org/springframework/security/cas/SamlServiceProperties.java b/cas/src/main/java/org/springframework/security/cas/SamlServiceProperties.java index 101a2374e0..15ead68d8d 100644 --- a/cas/src/main/java/org/springframework/security/cas/SamlServiceProperties.java +++ b/cas/src/main/java/org/springframework/security/cas/SamlServiceProperties.java @@ -18,7 +18,6 @@ package org.springframework.security.cas; * Sets the appropriate parameters for CAS's implementation of SAML (which is not guaranteed to be actually SAML compliant). * * @author Scott Battaglia - * @version $Revision$ $Date$ * @since 3.0 */ public final class SamlServiceProperties extends ServiceProperties { diff --git a/cas/src/main/java/org/springframework/security/cas/ServiceProperties.java b/cas/src/main/java/org/springframework/security/cas/ServiceProperties.java index 1004a3d100..f6488df0aa 100644 --- a/cas/src/main/java/org/springframework/security/cas/ServiceProperties.java +++ b/cas/src/main/java/org/springframework/security/cas/ServiceProperties.java @@ -27,7 +27,6 @@ import org.springframework.util.Assert; * that is being secured by Spring Security. * * @author Ben Alex - * @version $Id$ */ public class ServiceProperties implements InitializingBean { diff --git a/cas/src/main/java/org/springframework/security/cas/authentication/CasAssertionAuthenticationToken.java b/cas/src/main/java/org/springframework/security/cas/authentication/CasAssertionAuthenticationToken.java index cb737bfa39..8db8b8fb98 100644 --- a/cas/src/main/java/org/springframework/security/cas/authentication/CasAssertionAuthenticationToken.java +++ b/cas/src/main/java/org/springframework/security/cas/authentication/CasAssertionAuthenticationToken.java @@ -24,7 +24,6 @@ import org.springframework.security.core.GrantedAuthority; * Temporary authentication object needed to load the user details service. * * @author Scott Battaglia - * @version $Id$ * @since 3.0 */ public final class CasAssertionAuthenticationToken extends AbstractAuthenticationToken { diff --git a/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationProvider.java b/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationProvider.java index c690040ddd..68b82652b5 100644 --- a/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationProvider.java +++ b/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationProvider.java @@ -46,7 +46,6 @@ import org.springframework.util.Assert; * * @author Ben Alex * @author Scott Battaglia - * @version $Id$ */ public class CasAuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware { diff --git a/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationToken.java b/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationToken.java index a3ff108c75..373871b392 100644 --- a/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationToken.java +++ b/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationToken.java @@ -28,7 +28,6 @@ import org.springframework.security.core.userdetails.UserDetails; * * @author Ben Alex * @author Scott Battaglia - * @version $Id$ */ public class CasAuthenticationToken extends AbstractAuthenticationToken implements Serializable { //~ Instance fields ================================================================================================ diff --git a/cas/src/main/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCache.java b/cas/src/main/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCache.java index bef07631cc..abbc5c79a0 100644 --- a/cas/src/main/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCache.java +++ b/cas/src/main/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCache.java @@ -34,7 +34,6 @@ import org.springframework.util.Assert; * Caches tickets using a Spring IoC defined EHCACHE. * * @author Ben Alex - * @version $Id$ */ public class EhCacheBasedTicketCache implements StatelessTicketCache, InitializingBean { //~ Static fields/initializers ===================================================================================== diff --git a/cas/src/main/java/org/springframework/security/cas/authentication/NullStatelessTicketCache.java b/cas/src/main/java/org/springframework/security/cas/authentication/NullStatelessTicketCache.java index 131bb3e6d4..9f63863ef7 100644 --- a/cas/src/main/java/org/springframework/security/cas/authentication/NullStatelessTicketCache.java +++ b/cas/src/main/java/org/springframework/security/cas/authentication/NullStatelessTicketCache.java @@ -1,60 +1,59 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.security.cas.authentication; - - -/** - * Implementation of @link {@link StatelessTicketCache} that has no backing cache. Useful - * in instances where storing of tickets for stateless session management is not required. - *

- * This is the default StatelessTicketCache of the @link {@link CasAuthenticationProvider} to - * eliminate the unnecessary dependency on EhCache that applications have even if they are not using - * the stateless session management. - * - * @author Scott Battaglia - * @version $Id$ - * - *@see CasAuthenticationProvider - */ -public final class NullStatelessTicketCache implements StatelessTicketCache { - - /** - * @return null since we are not storing any tickets. - */ - public CasAuthenticationToken getByTicketId(final String serviceTicket) { - return null; - } - - /** - * This is a no-op since we are not storing tickets. - */ - public void putTicketInCache(final CasAuthenticationToken token) { - // nothing to do - } - - /** - * This is a no-op since we are not storing tickets. - */ - public void removeTicketFromCache(final CasAuthenticationToken token) { - // nothing to do - } - - /** - * This is a no-op since we are not storing tickets. - */ - public void removeTicketFromCache(final String serviceTicket) { - // nothing to do - } -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.security.cas.authentication; + + +/** + * Implementation of @link {@link StatelessTicketCache} that has no backing cache. Useful + * in instances where storing of tickets for stateless session management is not required. + *

+ * This is the default StatelessTicketCache of the @link {@link CasAuthenticationProvider} to + * eliminate the unnecessary dependency on EhCache that applications have even if they are not using + * the stateless session management. + * + * @author Scott Battaglia + * + *@see CasAuthenticationProvider + */ +public final class NullStatelessTicketCache implements StatelessTicketCache { + + /** + * @return null since we are not storing any tickets. + */ + public CasAuthenticationToken getByTicketId(final String serviceTicket) { + return null; + } + + /** + * This is a no-op since we are not storing tickets. + */ + public void putTicketInCache(final CasAuthenticationToken token) { + // nothing to do + } + + /** + * This is a no-op since we are not storing tickets. + */ + public void removeTicketFromCache(final CasAuthenticationToken token) { + // nothing to do + } + + /** + * This is a no-op since we are not storing tickets. + */ + public void removeTicketFromCache(final String serviceTicket) { + // nothing to do + } +} diff --git a/cas/src/main/java/org/springframework/security/cas/authentication/StatelessTicketCache.java b/cas/src/main/java/org/springframework/security/cas/authentication/StatelessTicketCache.java index a0500bcb47..6d9b22ec54 100644 --- a/cas/src/main/java/org/springframework/security/cas/authentication/StatelessTicketCache.java +++ b/cas/src/main/java/org/springframework/security/cas/authentication/StatelessTicketCache.java @@ -57,7 +57,6 @@ package org.springframework.security.cas.authentication; *

* * @author Ben Alex - * @version $Id$ */ public interface StatelessTicketCache { //~ Methods ================================================================ diff --git a/cas/src/main/java/org/springframework/security/cas/userdetails/AbstractCasAssertionUserDetailsService.java b/cas/src/main/java/org/springframework/security/cas/userdetails/AbstractCasAssertionUserDetailsService.java index 9028dcec74..c62885b104 100644 --- a/cas/src/main/java/org/springframework/security/cas/userdetails/AbstractCasAssertionUserDetailsService.java +++ b/cas/src/main/java/org/springframework/security/cas/userdetails/AbstractCasAssertionUserDetailsService.java @@ -27,7 +27,6 @@ import org.jasig.cas.client.validation.Assertion; * useful when combined with a SAML-based response from the CAS Server/client. * * @author Scott Battaglia - * @version $Revision$ $Date$ * @since 3.0 */ public abstract class AbstractCasAssertionUserDetailsService implements AuthenticationUserDetailsService { diff --git a/cas/src/main/java/org/springframework/security/cas/userdetails/GrantedAuthorityFromAssertionAttributesUserDetailsService.java b/cas/src/main/java/org/springframework/security/cas/userdetails/GrantedAuthorityFromAssertionAttributesUserDetailsService.java index 7251f3de69..b6adc850f0 100644 --- a/cas/src/main/java/org/springframework/security/cas/userdetails/GrantedAuthorityFromAssertionAttributesUserDetailsService.java +++ b/cas/src/main/java/org/springframework/security/cas/userdetails/GrantedAuthorityFromAssertionAttributesUserDetailsService.java @@ -30,7 +30,6 @@ import java.util.ArrayList; * value then its not added. * * @author Scott Battaglia - * @version $Revision$ $Date$ * @since 3.0 */ public final class GrantedAuthorityFromAssertionAttributesUserDetailsService extends AbstractCasAssertionUserDetailsService { diff --git a/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationEntryPoint.java b/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationEntryPoint.java index de96842f8e..cb4a8a2146 100644 --- a/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationEntryPoint.java +++ b/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationEntryPoint.java @@ -33,7 +33,7 @@ import org.springframework.util.Assert; * Used by the ExceptionTranslationFilter to commence authentication via the JA-SIG Central * Authentication Service (CAS). *

- * The user's browser will be redirected to the JA-SIG CAS enterprise-wide login page. + * The user's browser will be redirected to the JA-SIG CAS enterprise-wide login page. * This page is specified by the loginUrl property. Once login is complete, the CAS login page will * redirect to the page indicated by the service property. The service is a HTTP URL * belonging to the current application. The service URL is monitored by the {@link CasAuthenticationFilter}, @@ -41,7 +41,6 @@ import org.springframework.util.Assert; * * @author Ben Alex * @author Scott Battaglia - * @version $Id$ */ public class CasAuthenticationEntryPoint implements AuthenticationEntryPoint, InitializingBean { //~ Instance fields ================================================================================================ @@ -83,7 +82,7 @@ public class CasAuthenticationEntryPoint implements AuthenticationEntryPoint, In * Constructs a new Service Url. The default implementation relies on the CAS client to do the bulk of the work. * @param request the HttpServletRequest * @param response the HttpServlet Response - * @return the constructed service url. CANNOT be NULL. + * @return the constructed service url. CANNOT be NULL. */ protected String createServiceUrl(final HttpServletRequest request, final HttpServletResponse response) { return CommonUtils.constructServiceUrl(null, response, this.serviceProperties.getService(), null, this.serviceProperties.getArtifactParameter(), this.encodeServiceUrlWithSessionId); @@ -101,7 +100,7 @@ public class CasAuthenticationEntryPoint implements AuthenticationEntryPoint, In /** * Template method for you to do your own pre-processing before the redirect occurs. - * + * * @param request the HttpServletRequest * @param response the HttpServletResponse */ diff --git a/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationFilter.java b/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationFilter.java index d652ee3342..314a1fdfd2 100644 --- a/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationFilter.java +++ b/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationFilter.java @@ -54,7 +54,6 @@ import org.springframework.security.web.authentication.AbstractAuthenticationPro * By default this filter processes the URL /j_spring_cas_security_check. * * @author Ben Alex - * @version $Id$ */ public class CasAuthenticationFilter extends AbstractAuthenticationProcessingFilter { //~ Static fields/initializers ===================================================================================== diff --git a/cas/src/main/java/org/springframework/security/cas/web/package.html b/cas/src/main/java/org/springframework/security/cas/web/package.html index beb6fde0b1..ab7677598f 100644 --- a/cas/src/main/java/org/springframework/security/cas/web/package.html +++ b/cas/src/main/java/org/springframework/security/cas/web/package.html @@ -1,6 +1,6 @@ -Authenticates standard web browser users via +Authenticates standard web browser users via JA-SIG Central Authentication Service (CAS). diff --git a/cas/src/test/java/org/springframework/security/cas/authentication/AbstractStatelessTicketCacheTests.java b/cas/src/test/java/org/springframework/security/cas/authentication/AbstractStatelessTicketCacheTests.java index daf042ee71..a62d3f6049 100644 --- a/cas/src/test/java/org/springframework/security/cas/authentication/AbstractStatelessTicketCacheTests.java +++ b/cas/src/test/java/org/springframework/security/cas/authentication/AbstractStatelessTicketCacheTests.java @@ -1,32 +1,31 @@ -package org.springframework.security.cas.authentication; - -import java.util.ArrayList; -import java.util.List; - -import org.jasig.cas.client.validation.Assertion; -import org.jasig.cas.client.validation.AssertionImpl; -import org.springframework.security.cas.authentication.CasAuthenticationToken; -import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.core.userdetails.User; - -/** - * - * @author Scott Battaglia - * @version $Id$ - * @since 2.0 - * - */ -public abstract class AbstractStatelessTicketCacheTests { - - protected CasAuthenticationToken getToken() { - List proxyList = new ArrayList(); - proxyList.add("https://localhost/newPortal/j_spring_cas_security_check"); - - User user = new User("rod", "password", true, true, true, true, AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO")); - final Assertion assertion = new AssertionImpl("rod"); - - return new CasAuthenticationToken("key", user, "ST-0-ER94xMJmn6pha35CQRoZ", - AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"), user, assertion); - } - -} +package org.springframework.security.cas.authentication; + +import java.util.ArrayList; +import java.util.List; + +import org.jasig.cas.client.validation.Assertion; +import org.jasig.cas.client.validation.AssertionImpl; +import org.springframework.security.cas.authentication.CasAuthenticationToken; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.userdetails.User; + +/** + * + * @author Scott Battaglia + * @since 2.0 + * + */ +public abstract class AbstractStatelessTicketCacheTests { + + protected CasAuthenticationToken getToken() { + List proxyList = new ArrayList(); + proxyList.add("https://localhost/newPortal/j_spring_cas_security_check"); + + User user = new User("rod", "password", true, true, true, true, AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO")); + final Assertion assertion = new AssertionImpl("rod"); + + return new CasAuthenticationToken("key", user, "ST-0-ER94xMJmn6pha35CQRoZ", + AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"), user, assertion); + } + +} diff --git a/cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationProviderTests.java b/cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationProviderTests.java index 0e200feaeb..41818e9955 100644 --- a/cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationProviderTests.java +++ b/cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationProviderTests.java @@ -46,7 +46,6 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException; * * @author Ben Alex * @author Scott Battaglia - * @version $Id$ */ public class CasAuthenticationProviderTests { //~ Methods ======================================================================================================== diff --git a/cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationTokenTests.java b/cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationTokenTests.java index eeaabe9a4b..b43501a813 100644 --- a/cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationTokenTests.java +++ b/cas/src/test/java/org/springframework/security/cas/authentication/CasAuthenticationTokenTests.java @@ -32,7 +32,6 @@ import org.springframework.security.core.userdetails.UserDetails; * Tests {@link CasAuthenticationToken}. * * @author Ben Alex - * @version $Id$ */ public class CasAuthenticationTokenTests extends TestCase { private final List ROLES = AuthorityUtils.createAuthorityList("ROLE_ONE","ROLE_TWO"); diff --git a/cas/src/test/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCacheTests.java b/cas/src/test/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCacheTests.java index 8b843369eb..ae76b3d223 100644 --- a/cas/src/test/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCacheTests.java +++ b/cas/src/test/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCacheTests.java @@ -32,7 +32,6 @@ import static org.junit.Assert.*; * Tests {@link EhCacheBasedTicketCache}. * * @author Ben Alex - * @version $Id$ */ public class EhCacheBasedTicketCacheTests extends AbstractStatelessTicketCacheTests { private static CacheManager cacheManager; @@ -55,7 +54,7 @@ public class EhCacheBasedTicketCacheTests extends AbstractStatelessTicketCacheTe EhCacheBasedTicketCache cache = new EhCacheBasedTicketCache(); cache.setCache(cacheManager.getCache("castickets")); cache.afterPropertiesSet(); - + final CasAuthenticationToken token = getToken(); // Check it gets stored in the cache diff --git a/cas/src/test/java/org/springframework/security/cas/authentication/NullStatelessTicketCacheTests.java b/cas/src/test/java/org/springframework/security/cas/authentication/NullStatelessTicketCacheTests.java index 4939053142..abf0e0c72d 100644 --- a/cas/src/test/java/org/springframework/security/cas/authentication/NullStatelessTicketCacheTests.java +++ b/cas/src/test/java/org/springframework/security/cas/authentication/NullStatelessTicketCacheTests.java @@ -1,48 +1,47 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.security.cas.authentication; - - -import org.junit.Test; -import org.springframework.security.cas.authentication.CasAuthenticationToken; -import org.springframework.security.cas.authentication.NullStatelessTicketCache; -import org.springframework.security.cas.authentication.StatelessTicketCache; - -import static org.junit.Assert.*; - -/** - * Test cases for the @link {@link NullStatelessTicketCache} - * - * @author Scott Battaglia - * @version $Id$ - * - */ -public class NullStatelessTicketCacheTests extends AbstractStatelessTicketCacheTests { - - private StatelessTicketCache cache = new NullStatelessTicketCache(); - - @Test - public void testGetter() { - assertNull(cache.getByTicketId(null)); - assertNull(cache.getByTicketId("test")); - } - - @Test - public void testInsertAndGet() { - final CasAuthenticationToken token = getToken(); - cache.putTicketInCache(token); - assertNull(cache.getByTicketId((String) token.getCredentials())); - } -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.security.cas.authentication; + + +import org.junit.Test; +import org.springframework.security.cas.authentication.CasAuthenticationToken; +import org.springframework.security.cas.authentication.NullStatelessTicketCache; +import org.springframework.security.cas.authentication.StatelessTicketCache; + +import static org.junit.Assert.*; + +/** + * Test cases for the @link {@link NullStatelessTicketCache} + * + * @author Scott Battaglia + * + */ +public class NullStatelessTicketCacheTests extends AbstractStatelessTicketCacheTests { + + private StatelessTicketCache cache = new NullStatelessTicketCache(); + + @Test + public void testGetter() { + assertNull(cache.getByTicketId(null)); + assertNull(cache.getByTicketId("test")); + } + + @Test + public void testInsertAndGet() { + final CasAuthenticationToken token = getToken(); + cache.putTicketInCache(token); + assertNull(cache.getByTicketId((String) token.getCredentials())); + } +} diff --git a/cas/src/test/java/org/springframework/security/cas/web/CasAuthenticationEntryPointTests.java b/cas/src/test/java/org/springframework/security/cas/web/CasAuthenticationEntryPointTests.java index dcb76d08e4..5349fc4e94 100644 --- a/cas/src/test/java/org/springframework/security/cas/web/CasAuthenticationEntryPointTests.java +++ b/cas/src/test/java/org/springframework/security/cas/web/CasAuthenticationEntryPointTests.java @@ -29,7 +29,6 @@ import java.net.URLEncoder; * Tests {@link CasAuthenticationEntryPoint}. * * @author Ben Alex - * @version $Id$ */ public class CasAuthenticationEntryPointTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/cas/src/test/java/org/springframework/security/cas/web/CasAuthenticationFilterTests.java b/cas/src/test/java/org/springframework/security/cas/web/CasAuthenticationFilterTests.java index 2b4f6db9de..e3221b722e 100644 --- a/cas/src/test/java/org/springframework/security/cas/web/CasAuthenticationFilterTests.java +++ b/cas/src/test/java/org/springframework/security/cas/web/CasAuthenticationFilterTests.java @@ -30,7 +30,6 @@ import org.springframework.security.core.AuthenticationException; * Tests {@link CasAuthenticationFilter}. * * @author Ben Alex - * @version $Id$ */ public class CasAuthenticationFilterTests { //~ Methods ======================================================================================================== diff --git a/cas/src/test/java/org/springframework/security/cas/web/ServicePropertiesTests.java b/cas/src/test/java/org/springframework/security/cas/web/ServicePropertiesTests.java index d939239337..a313bc8a24 100644 --- a/cas/src/test/java/org/springframework/security/cas/web/ServicePropertiesTests.java +++ b/cas/src/test/java/org/springframework/security/cas/web/ServicePropertiesTests.java @@ -24,7 +24,6 @@ import junit.framework.TestCase; * Tests {@link ServiceProperties}. * * @author Ben Alex - * @version $Id$ */ public class ServicePropertiesTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/config/src/main/java/org/springframework/security/config/BeanIds.java b/config/src/main/java/org/springframework/security/config/BeanIds.java index c443618b5b..b81b52fa9b 100644 --- a/config/src/main/java/org/springframework/security/config/BeanIds.java +++ b/config/src/main/java/org/springframework/security/config/BeanIds.java @@ -6,7 +6,6 @@ package org.springframework.security.config; * These are intended for internal use. * * @author Ben Alex - * @version $Id: BeanIds.java 3770 2009-07-15 23:09:47Z ltaylor $ */ public abstract class BeanIds { private static final String PREFIX = "org.springframework.security."; diff --git a/config/src/main/java/org/springframework/security/config/Elements.java b/config/src/main/java/org/springframework/security/config/Elements.java index 5be9194197..fb101232cb 100644 --- a/config/src/main/java/org/springframework/security/config/Elements.java +++ b/config/src/main/java/org/springframework/security/config/Elements.java @@ -4,7 +4,6 @@ package org.springframework.security.config; * Contains all the element names used by Spring Security 2 namespace support. * * @author Ben Alex - * @version $Id: Elements.java 3697 2009-06-08 12:59:13Z ltaylor $ */ public abstract class Elements { diff --git a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java index 8f7fd15434..9d8e6b383d 100644 --- a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java +++ b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java @@ -31,7 +31,6 @@ import org.w3c.dom.Node; * @author Luke Taylor * @author Ben Alex * @since 2.0 - * @version $Id$ */ public final class SecurityNamespaceHandler implements NamespaceHandler { private final Map parsers = new HashMap(); diff --git a/config/src/main/java/org/springframework/security/config/authentication/AbstractUserDetailsServiceBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/authentication/AbstractUserDetailsServiceBeanDefinitionParser.java index 8696e2c8f7..1f34afc6ac 100644 --- a/config/src/main/java/org/springframework/security/config/authentication/AbstractUserDetailsServiceBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/authentication/AbstractUserDetailsServiceBeanDefinitionParser.java @@ -17,7 +17,6 @@ import org.w3c.dom.Element; /** * @author Luke Taylor - * @version $Id$ */ public abstract class AbstractUserDetailsServiceBeanDefinitionParser implements BeanDefinitionParser { static final String CACHE_REF = "cache-ref"; diff --git a/config/src/main/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParser.java index 92931f2b5d..b517967a5e 100644 --- a/config/src/main/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParser.java @@ -31,7 +31,6 @@ import org.w3c.dom.NodeList; * coming from. * * @author Luke Taylor - * @version $Id$ */ public class AuthenticationManagerBeanDefinitionParser implements BeanDefinitionParser { private static final String ATT_ALIAS = "alias"; diff --git a/config/src/main/java/org/springframework/security/config/authentication/AuthenticationManagerFactoryBean.java b/config/src/main/java/org/springframework/security/config/authentication/AuthenticationManagerFactoryBean.java index 7f3eb0561c..4ddf15681e 100644 --- a/config/src/main/java/org/springframework/security/config/authentication/AuthenticationManagerFactoryBean.java +++ b/config/src/main/java/org/springframework/security/config/authentication/AuthenticationManagerFactoryBean.java @@ -15,7 +15,6 @@ import org.springframework.security.config.BeanIds; * the <authentication-manager> element. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class AuthenticationManagerFactoryBean implements FactoryBean, BeanFactoryAware { diff --git a/config/src/main/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParser.java index 0ac93d549d..fc4c3e6c4c 100644 --- a/config/src/main/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParser.java @@ -17,7 +17,6 @@ import org.w3c.dom.Element; * ProviderManager. * * @author Luke Taylor - * @version $Id$ */ public class AuthenticationProviderBeanDefinitionParser implements BeanDefinitionParser { private static String ATT_USER_DETAILS_REF = "user-service-ref"; diff --git a/config/src/main/java/org/springframework/security/config/authentication/JdbcUserServiceBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/authentication/JdbcUserServiceBeanDefinitionParser.java index 8809d580d1..dea8bcbed7 100644 --- a/config/src/main/java/org/springframework/security/config/authentication/JdbcUserServiceBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/authentication/JdbcUserServiceBeanDefinitionParser.java @@ -9,7 +9,6 @@ import org.w3c.dom.Element; /** * @author Luke Taylor - * @version $Id$ */ public class JdbcUserServiceBeanDefinitionParser extends AbstractUserDetailsServiceBeanDefinitionParser { static final String ATT_DATA_SOURCE = "data-source-ref"; diff --git a/config/src/main/java/org/springframework/security/config/authentication/PasswordEncoderParser.java b/config/src/main/java/org/springframework/security/config/authentication/PasswordEncoderParser.java index 9eeb2f8b65..8af2300363 100644 --- a/config/src/main/java/org/springframework/security/config/authentication/PasswordEncoderParser.java +++ b/config/src/main/java/org/springframework/security/config/authentication/PasswordEncoderParser.java @@ -29,7 +29,6 @@ import org.w3c.dom.Element; * Will produce a PasswordEncoder and (optionally) a SaltSource. * * @author Luke Taylor - * @version $Id$ */ public class PasswordEncoderParser { static final String ATT_REF = "ref"; diff --git a/config/src/main/java/org/springframework/security/config/authentication/SaltSourceBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/authentication/SaltSourceBeanDefinitionParser.java index 5c5d9694be..a8227bd121 100644 --- a/config/src/main/java/org/springframework/security/config/authentication/SaltSourceBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/authentication/SaltSourceBeanDefinitionParser.java @@ -13,7 +13,6 @@ import org.w3c.dom.Element; /** * @author Luke Taylor - * @version $Id$ * @since 2.0 */ class SaltSourceBeanDefinitionParser { diff --git a/config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java b/config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java index 5defb73308..448c025c2d 100644 --- a/config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java +++ b/config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java @@ -44,7 +44,6 @@ import org.w3c.dom.Element; * Handles creation of authentication mechanism filters and related beans for <http> parsing. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ final class AuthenticationConfigBuilder { diff --git a/config/src/main/java/org/springframework/security/config/http/ChannelAttributeFactory.java b/config/src/main/java/org/springframework/security/config/http/ChannelAttributeFactory.java index 0160ea03e0..41af43acc0 100644 --- a/config/src/main/java/org/springframework/security/config/http/ChannelAttributeFactory.java +++ b/config/src/main/java/org/springframework/security/config/http/ChannelAttributeFactory.java @@ -11,7 +11,6 @@ import org.springframework.security.web.access.channel.ChannelDecisionManagerImp * Used as a factory bean to create config attribute values for the requires-channel attribute. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class ChannelAttributeFactory { diff --git a/config/src/main/java/org/springframework/security/config/http/FilterChainMapBeanDefinitionDecorator.java b/config/src/main/java/org/springframework/security/config/http/FilterChainMapBeanDefinitionDecorator.java index f165a55e38..2490ea525f 100644 --- a/config/src/main/java/org/springframework/security/config/http/FilterChainMapBeanDefinitionDecorator.java +++ b/config/src/main/java/org/springframework/security/config/http/FilterChainMapBeanDefinitionDecorator.java @@ -20,7 +20,6 @@ import java.util.*; * Sets the filter chain Map for a FilterChainProxy bean declaration. * * @author Luke Taylor - * @version $Id$ */ public class FilterChainMapBeanDefinitionDecorator implements BeanDefinitionDecorator { diff --git a/config/src/main/java/org/springframework/security/config/http/FilterInvocationSecurityMetadataSourceParser.java b/config/src/main/java/org/springframework/security/config/http/FilterInvocationSecurityMetadataSourceParser.java index 84a5ae3149..66cdf3dcc9 100644 --- a/config/src/main/java/org/springframework/security/config/http/FilterInvocationSecurityMetadataSourceParser.java +++ b/config/src/main/java/org/springframework/security/config/http/FilterInvocationSecurityMetadataSourceParser.java @@ -28,7 +28,6 @@ import org.w3c.dom.Element; * Allows for convenient creation of a {@link FilterInvocationSecurityMetadataSource} bean for use with a FilterSecurityInterceptor. * * @author Luke Taylor - * @version $Id$ */ public class FilterInvocationSecurityMetadataSourceParser implements BeanDefinitionParser { private static final String ATT_USE_EXPRESSIONS = "use-expressions"; diff --git a/config/src/main/java/org/springframework/security/config/http/FormLoginBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/FormLoginBeanDefinitionParser.java index da8ee38f67..ecc44c79b2 100644 --- a/config/src/main/java/org/springframework/security/config/http/FormLoginBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/http/FormLoginBeanDefinitionParser.java @@ -17,7 +17,6 @@ import org.w3c.dom.Element; /** * @author Luke Taylor * @author Ben Alex - * @version $Id$ */ public class FormLoginBeanDefinitionParser { protected final Log logger = LogFactory.getLog(getClass()); diff --git a/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java b/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java index 7820aa9574..25eb38ad79 100644 --- a/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java +++ b/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java @@ -53,7 +53,6 @@ import org.w3c.dom.Element; * Stateful class which helps HttpSecurityBDP to create the configuration for the <http> element. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ class HttpConfigurationBuilder { diff --git a/config/src/main/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParser.java index dd9da5db62..b6f89ffd09 100644 --- a/config/src/main/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParser.java @@ -42,7 +42,6 @@ import org.w3c.dom.Element; * @author Luke Taylor * @author Ben Alex * @since 2.0 - * @version $Id$ */ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser { private static final Log logger = LogFactory.getLog(HttpSecurityBeanDefinitionParser.class); diff --git a/config/src/main/java/org/springframework/security/config/http/LogoutBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/LogoutBeanDefinitionParser.java index 4976e2cd47..4697c56992 100644 --- a/config/src/main/java/org/springframework/security/config/http/LogoutBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/http/LogoutBeanDefinitionParser.java @@ -14,7 +14,6 @@ import org.w3c.dom.Element; /** * @author Luke Taylor * @author Ben Alex - * @version $Id$ */ class LogoutBeanDefinitionParser implements BeanDefinitionParser { static final String ATT_LOGOUT_SUCCESS_URL = "logout-success-url"; diff --git a/config/src/main/java/org/springframework/security/config/http/PortMappingsBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/PortMappingsBeanDefinitionParser.java index e4903f09ca..42cfc5de4f 100644 --- a/config/src/main/java/org/springframework/security/config/http/PortMappingsBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/http/PortMappingsBeanDefinitionParser.java @@ -19,7 +19,6 @@ import org.w3c.dom.Element; * bean. * * @author Luke Taylor - * @version $Id$ */ class PortMappingsBeanDefinitionParser implements BeanDefinitionParser { public static final String ATT_HTTP_PORT = "http"; diff --git a/config/src/main/java/org/springframework/security/config/http/RememberMeBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/RememberMeBeanDefinitionParser.java index 8e0198c59e..c6dbf713db 100644 --- a/config/src/main/java/org/springframework/security/config/http/RememberMeBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/http/RememberMeBeanDefinitionParser.java @@ -20,7 +20,6 @@ import org.w3c.dom.Element; /** * @author Luke Taylor * @author Ben Alex - * @version $Id$ */ class RememberMeBeanDefinitionParser implements BeanDefinitionParser { static final String ATT_DATA_SOURCE = "data-source-ref"; diff --git a/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java b/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java index 0adeb8c461..af9ea1926c 100644 --- a/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java +++ b/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java @@ -5,7 +5,6 @@ package org.springframework.security.config.http; * Stores the default order numbers of all Spring Security filters for use in configuration. * * @author Luke Taylor - * @version $Id$ */ enum SecurityFilters { diff --git a/config/src/main/java/org/springframework/security/config/http/WebConfigUtils.java b/config/src/main/java/org/springframework/security/config/http/WebConfigUtils.java index 538d98ed58..95d8c95bc9 100644 --- a/config/src/main/java/org/springframework/security/config/http/WebConfigUtils.java +++ b/config/src/main/java/org/springframework/security/config/http/WebConfigUtils.java @@ -9,7 +9,6 @@ import org.springframework.util.StringUtils; * * @author Luke Taylor * @author Ben Alex - * @version $Id$ */ abstract class WebConfigUtils { diff --git a/config/src/main/java/org/springframework/security/config/ldap/ContextSourceSettingPostProcessor.java b/config/src/main/java/org/springframework/security/config/ldap/ContextSourceSettingPostProcessor.java index 193b145106..3fa3c5b2e8 100644 --- a/config/src/main/java/org/springframework/security/config/ldap/ContextSourceSettingPostProcessor.java +++ b/config/src/main/java/org/springframework/security/config/ldap/ContextSourceSettingPostProcessor.java @@ -16,7 +16,6 @@ import org.springframework.util.ClassUtils; * the server-ref attribute to link this to the other ldap definitions. See SEC-799. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ class ContextSourceSettingPostProcessor implements BeanFactoryPostProcessor, Ordered { diff --git a/config/src/main/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParser.java index bea6f4cee3..3a6b93dab2 100644 --- a/config/src/main/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParser.java @@ -17,7 +17,6 @@ import org.w3c.dom.Element; * Ldap authentication provider namespace configuration. * * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public class LdapProviderBeanDefinitionParser implements BeanDefinitionParser { diff --git a/config/src/main/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParser.java index 103108434f..11c412723f 100644 --- a/config/src/main/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParser.java @@ -14,7 +14,6 @@ import org.w3c.dom.Element; /** * @author Luke Taylor - * @version $Id$ */ public class LdapServerBeanDefinitionParser implements BeanDefinitionParser { private static final String CONTEXT_SOURCE_CLASS="org.springframework.security.ldap.DefaultSpringSecurityContextSource"; diff --git a/config/src/main/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParser.java index 4d17d0c40d..2d708002d5 100644 --- a/config/src/main/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParser.java @@ -15,7 +15,6 @@ import org.w3c.dom.Element; /** * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public class LdapUserServiceBeanDefinitionParser extends AbstractUserDetailsServiceBeanDefinitionParser { diff --git a/config/src/main/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParser.java index 4024e2f553..618b264979 100644 --- a/config/src/main/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParser.java @@ -62,7 +62,6 @@ import org.w3c.dom.Element; * * @author Ben Alex * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionParser { diff --git a/config/src/main/java/org/springframework/security/config/method/InterceptMethodsBeanDefinitionDecorator.java b/config/src/main/java/org/springframework/security/config/method/InterceptMethodsBeanDefinitionDecorator.java index 5fe39f2172..0be451b67c 100644 --- a/config/src/main/java/org/springframework/security/config/method/InterceptMethodsBeanDefinitionDecorator.java +++ b/config/src/main/java/org/springframework/security/config/method/InterceptMethodsBeanDefinitionDecorator.java @@ -27,7 +27,6 @@ import org.w3c.dom.Node; * @author Luke Taylor * @author Ben Alex * - * @version $Id$ */ public class InterceptMethodsBeanDefinitionDecorator implements BeanDefinitionDecorator { private BeanDefinitionDecorator delegate = new InternalInterceptMethodsBeanDefinitionDecorator(); diff --git a/config/src/main/java/org/springframework/security/config/method/MethodConfigUtils.java b/config/src/main/java/org/springframework/security/config/method/MethodConfigUtils.java index d3deb0e01e..41aff3e24d 100644 --- a/config/src/main/java/org/springframework/security/config/method/MethodConfigUtils.java +++ b/config/src/main/java/org/springframework/security/config/method/MethodConfigUtils.java @@ -15,7 +15,6 @@ import org.springframework.security.config.BeanIds; * * @author Luke Taylor * @author Ben Alex - * @version $Id: WebConfigUtils.java 3770 2009-07-15 23:09:47Z ltaylor $ */ abstract class MethodConfigUtils { @SuppressWarnings("unchecked") diff --git a/config/src/main/java/org/springframework/security/config/method/ProtectPointcutPostProcessor.java b/config/src/main/java/org/springframework/security/config/method/ProtectPointcutPostProcessor.java index 03c81ec9b2..7f8be45289 100644 --- a/config/src/main/java/org/springframework/security/config/method/ProtectPointcutPostProcessor.java +++ b/config/src/main/java/org/springframework/security/config/method/ProtectPointcutPostProcessor.java @@ -43,7 +43,6 @@ import org.springframework.util.StringUtils; * expression evaluation. * * @author Ben Alex - * @version $Id$ * @since 2.0 * */ diff --git a/config/src/main/resources/org/springframework/security/config/spring-security.xsl b/config/src/main/resources/org/springframework/security/config/spring-security.xsl index 3cb7f92637..7f8922d88c 100644 --- a/config/src/main/resources/org/springframework/security/config/spring-security.xsl +++ b/config/src/main/resources/org/springframework/security/config/spring-security.xsl @@ -3,7 +3,6 @@ diff --git a/config/src/test/java/org/springframework/security/config/DataSourcePopulator.java b/config/src/test/java/org/springframework/security/config/DataSourcePopulator.java index ce24d73151..43ee33bb97 100644 --- a/config/src/test/java/org/springframework/security/config/DataSourcePopulator.java +++ b/config/src/test/java/org/springframework/security/config/DataSourcePopulator.java @@ -25,7 +25,6 @@ import org.springframework.util.Assert; * Populates a database with test data for JDBC testing. * * @author Ben Alex - * @version $Id: DataSourcePopulator.java 2291 2007-12-03 02:56:52Z benalex $ */ public class DataSourcePopulator implements InitializingBean { //~ Instance fields ================================================================================================ diff --git a/config/src/test/java/org/springframework/security/config/FilterChainProxyConfigTests.java b/config/src/test/java/org/springframework/security/config/FilterChainProxyConfigTests.java index 72adc8f0f4..6e1e73bb28 100644 --- a/config/src/test/java/org/springframework/security/config/FilterChainProxyConfigTests.java +++ b/config/src/test/java/org/springframework/security/config/FilterChainProxyConfigTests.java @@ -43,7 +43,6 @@ import org.springframework.security.web.servletapi.SecurityContextHolderAwareReq * * @author Carlos Sanchez * @author Ben Alex - * @version $Id$ */ public class FilterChainProxyConfigTests { private ClassPathXmlApplicationContext appCtx; diff --git a/config/src/test/java/org/springframework/security/config/InvalidConfigurationTests.java b/config/src/test/java/org/springframework/security/config/InvalidConfigurationTests.java index 49c421b832..23218dde66 100644 --- a/config/src/test/java/org/springframework/security/config/InvalidConfigurationTests.java +++ b/config/src/test/java/org/springframework/security/config/InvalidConfigurationTests.java @@ -16,7 +16,6 @@ import org.springframework.security.config.util.InMemoryXmlApplicationContext; * transform has not been applied. * * @author Luke Taylor - * @version $Id$ */ public class InvalidConfigurationTests { private InMemoryXmlApplicationContext appContext; diff --git a/config/src/test/java/org/springframework/security/config/MockUserServiceBeanPostProcessor.java b/config/src/test/java/org/springframework/security/config/MockUserServiceBeanPostProcessor.java index d54e719b6c..c7107db622 100644 --- a/config/src/test/java/org/springframework/security/config/MockUserServiceBeanPostProcessor.java +++ b/config/src/test/java/org/springframework/security/config/MockUserServiceBeanPostProcessor.java @@ -5,13 +5,12 @@ import org.springframework.beans.factory.config.BeanPostProcessor; /** * Test bean post processor which injects a message into a PostProcessedMockUserDetailsService. - * + * * @author Luke Taylor - * @version $Id: MockUserServiceBeanPostProcessor.java 3541 2009-03-23 04:23:48Z ltaylor $ */ public class MockUserServiceBeanPostProcessor implements BeanPostProcessor { - public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { + public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return bean; } @@ -19,7 +18,7 @@ public class MockUserServiceBeanPostProcessor implements BeanPostProcessor { if (bean instanceof PostProcessedMockUserDetailsService) { ((PostProcessedMockUserDetailsService)bean).setPostProcessorWasHere("Hello from the post processor!"); } - + return bean; } } diff --git a/config/src/test/java/org/springframework/security/config/SecurityNamespacehandlerTests.java b/config/src/test/java/org/springframework/security/config/SecurityNamespacehandlerTests.java index b36651589d..12d19ca476 100644 --- a/config/src/test/java/org/springframework/security/config/SecurityNamespacehandlerTests.java +++ b/config/src/test/java/org/springframework/security/config/SecurityNamespacehandlerTests.java @@ -9,7 +9,6 @@ import org.springframework.security.config.util.InMemoryXmlApplicationContext; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class SecurityNamespacehandlerTests { diff --git a/config/src/test/java/org/springframework/security/config/TestBusinessBean.java b/config/src/test/java/org/springframework/security/config/TestBusinessBean.java index eac97164b8..9b6f0968e7 100644 --- a/config/src/test/java/org/springframework/security/config/TestBusinessBean.java +++ b/config/src/test/java/org/springframework/security/config/TestBusinessBean.java @@ -2,7 +2,6 @@ package org.springframework.security.config; /** * @author luke - * @version $Id: TestBusinessBean.java 3541 2009-03-23 04:23:48Z ltaylor $ */ public interface TestBusinessBean { diff --git a/config/src/test/java/org/springframework/security/config/TestBusinessBeanImpl.java b/config/src/test/java/org/springframework/security/config/TestBusinessBeanImpl.java index 27f21a0601..7c7dffaf08 100644 --- a/config/src/test/java/org/springframework/security/config/TestBusinessBeanImpl.java +++ b/config/src/test/java/org/springframework/security/config/TestBusinessBeanImpl.java @@ -5,7 +5,6 @@ import org.springframework.context.ApplicationListener; /** * @author Luke Taylor - * @version $Id: TestBusinessBeanImpl.java 3729 2009-06-26 12:44:46Z ltaylor $ */ public class TestBusinessBeanImpl implements TestBusinessBean, ApplicationListener { public void setInteger(int i) { diff --git a/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java index 1d3a7f0ddb..c63e43735f 100644 --- a/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java @@ -19,7 +19,6 @@ import org.springframework.security.util.FieldUtils; /** * * @author Luke Taylor - * @version $Id$ */ public class AuthenticationManagerBeanDefinitionParserTests { private static final String CONTEXT = diff --git a/config/src/test/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParserTests.java index f0c8fe6d67..1b49ed5e7b 100644 --- a/config/src/test/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParserTests.java @@ -22,7 +22,6 @@ import java.util.List; * Tests for {@link AuthenticationProviderBeanDefinitionParser}. * * @author Luke Taylor - * @version $Id$ */ public class AuthenticationProviderBeanDefinitionParserTests { private AbstractXmlApplicationContext appContext; diff --git a/config/src/test/java/org/springframework/security/config/authentication/JdbcUserServiceBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/authentication/JdbcUserServiceBeanDefinitionParserTests.java index 3521881fae..e47639cff3 100644 --- a/config/src/test/java/org/springframework/security/config/authentication/JdbcUserServiceBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/authentication/JdbcUserServiceBeanDefinitionParserTests.java @@ -23,7 +23,6 @@ import org.w3c.dom.Element; /** * @author Ben Alex * @author Luke Taylor - * @version $Id$ */ public class JdbcUserServiceBeanDefinitionParserTests { private static String USER_CACHE_XML = ""; diff --git a/config/src/test/java/org/springframework/security/config/http/FilterSecurityMetadataSourceBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/http/FilterSecurityMetadataSourceBeanDefinitionParserTests.java index 439ea0b6a4..d9a5765948 100644 --- a/config/src/test/java/org/springframework/security/config/http/FilterSecurityMetadataSourceBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/http/FilterSecurityMetadataSourceBeanDefinitionParserTests.java @@ -22,7 +22,6 @@ import org.springframework.security.web.access.intercept.DefaultFilterInvocation /** * Tests for {@link FilterInvocationSecurityMetadataSourceParser}. * @author Luke Taylor - * @version $Id$ */ public class FilterSecurityMetadataSourceBeanDefinitionParserTests { private AbstractXmlApplicationContext appContext; diff --git a/config/src/test/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParserTests.java index d2351983c3..2a38298b4d 100644 --- a/config/src/test/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParserTests.java @@ -80,7 +80,6 @@ import org.springframework.util.ReflectionUtils; /** * @author Luke Taylor - * @version $Id$ */ public class HttpSecurityBeanDefinitionParserTests { private static final int AUTO_CONFIG_FILTERS = 11; diff --git a/config/src/test/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParserTests.java index 04f1cf8842..9ac3f15135 100644 --- a/config/src/test/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParserTests.java @@ -21,7 +21,6 @@ import org.springframework.security.util.FieldUtils; /** * @author Luke Taylor - * @version $Id$ */ public class LdapProviderBeanDefinitionParserTests { InMemoryXmlApplicationContext appCtx; diff --git a/config/src/test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTests.java index 2c9de7d2b1..72f44f9f13 100644 --- a/config/src/test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTests.java @@ -9,7 +9,6 @@ import org.springframework.security.ldap.DefaultSpringSecurityContextSource; /** * @author Luke Taylor - * @version $Id$ */ public class LdapServerBeanDefinitionParserTests { InMemoryXmlApplicationContext appCtx; diff --git a/config/src/test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java index 6357911ed9..2f1d44fe1d 100644 --- a/config/src/test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java @@ -26,7 +26,6 @@ import org.w3c.dom.Element; /** * @author Luke Taylor - * @version $Id$ */ public class LdapUserServiceBeanDefinitionParserTests { private InMemoryXmlApplicationContext appCtx; diff --git a/config/src/test/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParserTests.java index 8099aa2ec9..4717a4c969 100644 --- a/config/src/test/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParserTests.java @@ -38,7 +38,6 @@ import org.springframework.security.util.FieldUtils; /** * @author Ben Alex * @author Luke Taylor - * @version $Id$ */ public class GlobalMethodSecurityBeanDefinitionParserTests { private AbstractXmlApplicationContext appContext; diff --git a/config/src/test/java/org/springframework/security/config/method/InterceptMethodsBeanDefinitionDecoratorTests.java b/config/src/test/java/org/springframework/security/config/method/InterceptMethodsBeanDefinitionDecoratorTests.java index 8e8a32117b..d01196db53 100644 --- a/config/src/test/java/org/springframework/security/config/method/InterceptMethodsBeanDefinitionDecoratorTests.java +++ b/config/src/test/java/org/springframework/security/config/method/InterceptMethodsBeanDefinitionDecoratorTests.java @@ -18,7 +18,6 @@ import org.springframework.security.core.context.SecurityContextHolder; /** * @author Luke Taylor - * @version $Id$ */ public class InterceptMethodsBeanDefinitionDecoratorTests { private ClassPathXmlApplicationContext appContext; diff --git a/config/src/test/java/org/springframework/security/config/method/Jsr250AnnotationDrivenBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/method/Jsr250AnnotationDrivenBeanDefinitionParserTests.java index bfe88460e8..52fb9c02ab 100644 --- a/config/src/test/java/org/springframework/security/config/method/Jsr250AnnotationDrivenBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/method/Jsr250AnnotationDrivenBeanDefinitionParserTests.java @@ -14,7 +14,6 @@ import org.springframework.security.core.context.SecurityContextHolder; /** * @author Luke Taylor - * @version $Id$ */ public class Jsr250AnnotationDrivenBeanDefinitionParserTests { private InMemoryXmlApplicationContext appContext; diff --git a/config/src/test/java/org/springframework/security/config/method/SecuredAnnotationDrivenBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/method/SecuredAnnotationDrivenBeanDefinitionParserTests.java index ef21e04740..6c2209a336 100644 --- a/config/src/test/java/org/springframework/security/config/method/SecuredAnnotationDrivenBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/method/SecuredAnnotationDrivenBeanDefinitionParserTests.java @@ -14,7 +14,6 @@ import org.springframework.security.core.context.SecurityContextHolder; /** * @author Ben Alex - * @version $Id$ */ public class SecuredAnnotationDrivenBeanDefinitionParserTests { private InMemoryXmlApplicationContext appContext; diff --git a/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java b/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java index f5e50f03e5..8d4c1259a5 100644 --- a/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java +++ b/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java @@ -7,7 +7,6 @@ import org.springframework.security.util.InMemoryResource; /** * @author Luke Taylor - * @version $Id$ */ public class InMemoryXmlApplicationContext extends AbstractXmlApplicationContext { private static final String BEANS_OPENING = diff --git a/config/src/test/resources/namespace-usage.xml b/config/src/test/resources/namespace-usage.xml index f31f10f329..512a0c78df 100644 --- a/config/src/test/resources/namespace-usage.xml +++ b/config/src/test/resources/namespace-usage.xml @@ -1,8 +1,8 @@ - + - - + + - + diff --git a/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml b/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml index 468e22ec72..1aca6bfb2d 100644 --- a/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml +++ b/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml @@ -16,7 +16,6 @@ * limitations under the License. * * - * $Id: filtertest-valid.xml 3497 2008-12-20 00:16:49Z ltaylor $ --> javax.annotation jsr250-api - true - + true + log4j log4j diff --git a/core/src/main/java/org/springframework/security/access/AccessDecisionManager.java b/core/src/main/java/org/springframework/security/access/AccessDecisionManager.java index ed97d2f95e..1e58227975 100644 --- a/core/src/main/java/org/springframework/security/access/AccessDecisionManager.java +++ b/core/src/main/java/org/springframework/security/access/AccessDecisionManager.java @@ -24,7 +24,6 @@ import org.springframework.security.core.Authentication; * Makes a final access control (authorization) decision. * * @author Ben Alex - * @version $Id$ */ public interface AccessDecisionManager { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/AccessDecisionVoter.java b/core/src/main/java/org/springframework/security/access/AccessDecisionVoter.java index 411d0fc319..e38bf1c935 100644 --- a/core/src/main/java/org/springframework/security/access/AccessDecisionVoter.java +++ b/core/src/main/java/org/springframework/security/access/AccessDecisionVoter.java @@ -30,7 +30,6 @@ import org.springframework.security.core.Authentication; *

* * @author Ben Alex - * @version $Id$ */ public interface AccessDecisionVoter { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/AccessDeniedException.java b/core/src/main/java/org/springframework/security/access/AccessDeniedException.java index f7acb1c15a..42d9fb3669 100644 --- a/core/src/main/java/org/springframework/security/access/AccessDeniedException.java +++ b/core/src/main/java/org/springframework/security/access/AccessDeniedException.java @@ -20,7 +20,6 @@ package org.springframework.security.access; * required authority. * * @author Ben Alex - * @version $Id$ */ public class AccessDeniedException extends RuntimeException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/AfterInvocationProvider.java b/core/src/main/java/org/springframework/security/access/AfterInvocationProvider.java index 2070b0a157..8dc0b56596 100644 --- a/core/src/main/java/org/springframework/security/access/AfterInvocationProvider.java +++ b/core/src/main/java/org/springframework/security/access/AfterInvocationProvider.java @@ -25,7 +25,6 @@ import org.springframework.security.core.Authentication; * Indicates a class is responsible for participating in an {@link AfterInvocationProviderManager} decision. * * @author Ben Alex - * @version $Id$ */ public interface AfterInvocationProvider { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/AuthorizationServiceException.java b/core/src/main/java/org/springframework/security/access/AuthorizationServiceException.java index 9a530b7bb9..43f2d0a97d 100644 --- a/core/src/main/java/org/springframework/security/access/AuthorizationServiceException.java +++ b/core/src/main/java/org/springframework/security/access/AuthorizationServiceException.java @@ -22,7 +22,6 @@ package org.springframework.security.access; * argument, for example. * * @author Ben Alex - * @version $Id$ */ public class AuthorizationServiceException extends AccessDeniedException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/ConfigAttribute.java b/core/src/main/java/org/springframework/security/access/ConfigAttribute.java index 051efb13b3..4b1e9e823f 100644 --- a/core/src/main/java/org/springframework/security/access/ConfigAttribute.java +++ b/core/src/main/java/org/springframework/security/access/ConfigAttribute.java @@ -33,7 +33,6 @@ import org.springframework.security.access.intercept.RunAsManager; * Stored at runtime with other ConfigAttributes for the same secure object target. * * @author Ben Alex - * @version $Id$ */ public interface ConfigAttribute extends Serializable { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/ConfigAttributeEditor.java b/core/src/main/java/org/springframework/security/access/ConfigAttributeEditor.java index 8240ef78fc..a92fb0f40b 100644 --- a/core/src/main/java/org/springframework/security/access/ConfigAttributeEditor.java +++ b/core/src/main/java/org/springframework/security/access/ConfigAttributeEditor.java @@ -27,7 +27,6 @@ import java.beans.PropertyEditorSupport; * * @author Ben Alex * @deprecated - * @version $Id$ */ public class ConfigAttributeEditor extends PropertyEditorSupport { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/PermissionEvaluator.java b/core/src/main/java/org/springframework/security/access/PermissionEvaluator.java index 72f159357b..50e4d6ed45 100644 --- a/core/src/main/java/org/springframework/security/access/PermissionEvaluator.java +++ b/core/src/main/java/org/springframework/security/access/PermissionEvaluator.java @@ -10,7 +10,6 @@ import org.springframework.security.core.Authentication; * * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface PermissionEvaluator { diff --git a/core/src/main/java/org/springframework/security/access/SecurityConfig.java b/core/src/main/java/org/springframework/security/access/SecurityConfig.java index f13300844d..7e7430ef4b 100644 --- a/core/src/main/java/org/springframework/security/access/SecurityConfig.java +++ b/core/src/main/java/org/springframework/security/access/SecurityConfig.java @@ -25,7 +25,6 @@ import org.springframework.util.StringUtils; * Stores a {@link ConfigAttribute} as a String. * * @author Ben Alex - * @version $Id$ */ public class SecurityConfig implements ConfigAttribute { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/SecurityMetadataSource.java b/core/src/main/java/org/springframework/security/access/SecurityMetadataSource.java index 905b643d9f..b0633141fd 100644 --- a/core/src/main/java/org/springframework/security/access/SecurityMetadataSource.java +++ b/core/src/main/java/org/springframework/security/access/SecurityMetadataSource.java @@ -26,7 +26,6 @@ import org.springframework.security.access.intercept.AbstractSecurityInterceptor * invocation. * * @author Ben Alex - * @version $Id$ */ public interface SecurityMetadataSource extends AopInfrastructureBean { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/annotation/Jsr250MethodSecurityMetadataSource.java b/core/src/main/java/org/springframework/security/access/annotation/Jsr250MethodSecurityMetadataSource.java index cf07142241..541f207f83 100644 --- a/core/src/main/java/org/springframework/security/access/annotation/Jsr250MethodSecurityMetadataSource.java +++ b/core/src/main/java/org/springframework/security/access/annotation/Jsr250MethodSecurityMetadataSource.java @@ -34,7 +34,6 @@ import org.springframework.security.access.method.AbstractFallbackMethodSecurity * Sources method security metadata from major JSR 250 security annotations. * * @author Ben Alex - * @version $Id$ * @since 2.0 */ public class Jsr250MethodSecurityMetadataSource extends AbstractFallbackMethodSecurityMetadataSource { diff --git a/core/src/main/java/org/springframework/security/access/annotation/Secured.java b/core/src/main/java/org/springframework/security/access/annotation/Secured.java index aa9df1e4ef..8cd792d76c 100644 --- a/core/src/main/java/org/springframework/security/access/annotation/Secured.java +++ b/core/src/main/java/org/springframework/security/access/annotation/Secured.java @@ -40,7 +40,6 @@ import java.lang.annotation.Target; * public void delete(Contact contact); * * @author Mark St.Godard - * @version $Id$ */ @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/core/src/main/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataSource.java b/core/src/main/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataSource.java index 3c5fd537e9..162eeb52d3 100644 --- a/core/src/main/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataSource.java +++ b/core/src/main/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataSource.java @@ -31,7 +31,6 @@ import org.springframework.security.access.method.AbstractFallbackMethodSecurity * Sources method security metadata from Spring Security's {@link Secured} annotation. * * @author Ben Alex - * @version $Id$ */ public class SecuredAnnotationSecurityMetadataSource extends AbstractFallbackMethodSecurityMetadataSource { diff --git a/core/src/main/java/org/springframework/security/access/event/AbstractAuthorizationEvent.java b/core/src/main/java/org/springframework/security/access/event/AbstractAuthorizationEvent.java index 3a19049c73..64dd6530d3 100644 --- a/core/src/main/java/org/springframework/security/access/event/AbstractAuthorizationEvent.java +++ b/core/src/main/java/org/springframework/security/access/event/AbstractAuthorizationEvent.java @@ -22,7 +22,6 @@ import org.springframework.context.ApplicationEvent; * Abstract superclass for all security interception related events. * * @author Ben Alex - * @version $Id$ */ public abstract class AbstractAuthorizationEvent extends ApplicationEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/event/AuthenticationCredentialsNotFoundEvent.java b/core/src/main/java/org/springframework/security/access/event/AuthenticationCredentialsNotFoundEvent.java index 58a277240a..17d5cb4cda 100644 --- a/core/src/main/java/org/springframework/security/access/event/AuthenticationCredentialsNotFoundEvent.java +++ b/core/src/main/java/org/springframework/security/access/event/AuthenticationCredentialsNotFoundEvent.java @@ -26,7 +26,6 @@ import org.springframework.security.authentication.AuthenticationCredentialsNotF * the SecurityContextHolder. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationCredentialsNotFoundEvent extends AbstractAuthorizationEvent { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/event/AuthorizationFailureEvent.java b/core/src/main/java/org/springframework/security/access/event/AuthorizationFailureEvent.java index f626bf9b55..f3e685a6ed 100644 --- a/core/src/main/java/org/springframework/security/access/event/AuthorizationFailureEvent.java +++ b/core/src/main/java/org/springframework/security/access/event/AuthorizationFailureEvent.java @@ -31,7 +31,6 @@ import org.springframework.security.core.Authentication; * {@link org.springframework.security.access.intercept.AfterInvocationManager AfterInvocationManager}. * * @author Ben Alex - * @version $Id$ */ public class AuthorizationFailureEvent extends AbstractAuthorizationEvent { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/event/AuthorizedEvent.java b/core/src/main/java/org/springframework/security/access/event/AuthorizedEvent.java index b186d5bfe8..1f18725e36 100644 --- a/core/src/main/java/org/springframework/security/access/event/AuthorizedEvent.java +++ b/core/src/main/java/org/springframework/security/access/event/AuthorizedEvent.java @@ -26,7 +26,6 @@ import org.springframework.security.core.Authentication; * proceed.

* * @author Ben Alex - * @version $Id$ */ public class AuthorizedEvent extends AbstractAuthorizationEvent { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/event/LoggerListener.java b/core/src/main/java/org/springframework/security/access/event/LoggerListener.java index f5aa69b746..7411498781 100644 --- a/core/src/main/java/org/springframework/security/access/event/LoggerListener.java +++ b/core/src/main/java/org/springframework/security/access/event/LoggerListener.java @@ -28,7 +28,6 @@ import org.springframework.context.ApplicationListener; *

* * @author Ben Alex - * @version $Id$ */ public class LoggerListener implements ApplicationListener { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/event/PublicInvocationEvent.java b/core/src/main/java/org/springframework/security/access/event/PublicInvocationEvent.java index ccc1e16767..e53b494646 100644 --- a/core/src/main/java/org/springframework/security/access/event/PublicInvocationEvent.java +++ b/core/src/main/java/org/springframework/security/access/event/PublicInvocationEvent.java @@ -22,7 +22,6 @@ package org.springframework.security.access.event; *

Published just before the secure object attempts to proceed.

* * @author Ben Alex - * @version $Id$ */ public class PublicInvocationEvent extends AbstractAuthorizationEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/expression/SecurityExpressionRoot.java b/core/src/main/java/org/springframework/security/access/expression/SecurityExpressionRoot.java index 2ab7653837..0d6174a569 100644 --- a/core/src/main/java/org/springframework/security/access/expression/SecurityExpressionRoot.java +++ b/core/src/main/java/org/springframework/security/access/expression/SecurityExpressionRoot.java @@ -15,7 +15,6 @@ import org.springframework.security.core.authority.AuthorityUtils; * Base root object for use in Spring Security expression evaluations. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public abstract class SecurityExpressionRoot { diff --git a/core/src/main/java/org/springframework/security/access/expression/method/AbstractExpressionBasedMethodConfigAttribute.java b/core/src/main/java/org/springframework/security/access/expression/method/AbstractExpressionBasedMethodConfigAttribute.java index e02eb27a97..f0f1c05183 100644 --- a/core/src/main/java/org/springframework/security/access/expression/method/AbstractExpressionBasedMethodConfigAttribute.java +++ b/core/src/main/java/org/springframework/security/access/expression/method/AbstractExpressionBasedMethodConfigAttribute.java @@ -14,7 +14,6 @@ import org.springframework.util.Assert; * Either filter or authorization expressions may be null, but not both. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ abstract class AbstractExpressionBasedMethodConfigAttribute implements ConfigAttribute { diff --git a/core/src/main/java/org/springframework/security/access/expression/method/DefaultMethodSecurityExpressionHandler.java b/core/src/main/java/org/springframework/security/access/expression/method/DefaultMethodSecurityExpressionHandler.java index fb1fbdf7b1..b12b0d6ab8 100644 --- a/core/src/main/java/org/springframework/security/access/expression/method/DefaultMethodSecurityExpressionHandler.java +++ b/core/src/main/java/org/springframework/security/access/expression/method/DefaultMethodSecurityExpressionHandler.java @@ -27,7 +27,6 @@ import org.springframework.security.core.Authentication; * A single instance should usually be shared amongst the beans that require expression support. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class DefaultMethodSecurityExpressionHandler implements MethodSecurityExpressionHandler { diff --git a/core/src/main/java/org/springframework/security/access/expression/method/DenyAllPermissionEvaluator.java b/core/src/main/java/org/springframework/security/access/expression/method/DenyAllPermissionEvaluator.java index 0b9a0e9667..0c1783d0fc 100644 --- a/core/src/main/java/org/springframework/security/access/expression/method/DenyAllPermissionEvaluator.java +++ b/core/src/main/java/org/springframework/security/access/expression/method/DenyAllPermissionEvaluator.java @@ -12,7 +12,6 @@ import org.springframework.security.core.Authentication; * evaluation should not be required. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ class DenyAllPermissionEvaluator implements PermissionEvaluator { diff --git a/core/src/main/java/org/springframework/security/access/expression/method/ExpressionBasedAnnotationAttributeFactory.java b/core/src/main/java/org/springframework/security/access/expression/method/ExpressionBasedAnnotationAttributeFactory.java index 9705cbf3e2..48b2c50dc1 100644 --- a/core/src/main/java/org/springframework/security/access/expression/method/ExpressionBasedAnnotationAttributeFactory.java +++ b/core/src/main/java/org/springframework/security/access/expression/method/ExpressionBasedAnnotationAttributeFactory.java @@ -19,7 +19,6 @@ import org.springframework.security.access.prepost.PrePostInvocationAttributeFac * an expression to be evaluated at runtime. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class ExpressionBasedAnnotationAttributeFactory implements PrePostInvocationAttributeFactory { diff --git a/core/src/main/java/org/springframework/security/access/expression/method/ExpressionBasedPostInvocationAdvice.java b/core/src/main/java/org/springframework/security/access/expression/method/ExpressionBasedPostInvocationAdvice.java index 3cbf4811c9..ec73a04798 100644 --- a/core/src/main/java/org/springframework/security/access/expression/method/ExpressionBasedPostInvocationAdvice.java +++ b/core/src/main/java/org/springframework/security/access/expression/method/ExpressionBasedPostInvocationAdvice.java @@ -14,7 +14,6 @@ import org.springframework.security.core.Authentication; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class ExpressionBasedPostInvocationAdvice implements PostInvocationAuthorizationAdvice{ diff --git a/core/src/main/java/org/springframework/security/access/expression/method/ExpressionBasedPreInvocationAdvice.java b/core/src/main/java/org/springframework/security/access/expression/method/ExpressionBasedPreInvocationAdvice.java index 5b8432bc5b..c772088195 100644 --- a/core/src/main/java/org/springframework/security/access/expression/method/ExpressionBasedPreInvocationAdvice.java +++ b/core/src/main/java/org/springframework/security/access/expression/method/ExpressionBasedPreInvocationAdvice.java @@ -17,7 +17,6 @@ import org.springframework.security.core.Authentication; * Method pre-invocation handling based on expressions. * * @author Luke Taylor - * @version $Id$ * @since */ public class ExpressionBasedPreInvocationAdvice implements PreInvocationAuthorizationAdvice { diff --git a/core/src/main/java/org/springframework/security/access/expression/method/MethodSecurityExpressionHandler.java b/core/src/main/java/org/springframework/security/access/expression/method/MethodSecurityExpressionHandler.java index 09a7c57e15..588e43c2e7 100644 --- a/core/src/main/java/org/springframework/security/access/expression/method/MethodSecurityExpressionHandler.java +++ b/core/src/main/java/org/springframework/security/access/expression/method/MethodSecurityExpressionHandler.java @@ -11,7 +11,6 @@ import org.springframework.security.core.Authentication; * from the implementation of the underlying expression objects. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface MethodSecurityExpressionHandler { diff --git a/core/src/main/java/org/springframework/security/access/expression/method/MethodSecurityExpressionRoot.java b/core/src/main/java/org/springframework/security/access/expression/method/MethodSecurityExpressionRoot.java index 9781ff1637..44052f9fde 100644 --- a/core/src/main/java/org/springframework/security/access/expression/method/MethodSecurityExpressionRoot.java +++ b/core/src/main/java/org/springframework/security/access/expression/method/MethodSecurityExpressionRoot.java @@ -11,7 +11,6 @@ import org.springframework.security.core.Authentication; * Extended expression root object which contains extra method-specific functionality. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ class MethodSecurityExpressionRoot extends SecurityExpressionRoot { diff --git a/core/src/main/java/org/springframework/security/access/expression/method/PostInvocationExpressionAttribute.java b/core/src/main/java/org/springframework/security/access/expression/method/PostInvocationExpressionAttribute.java index 35ca79af69..7b30564d0a 100644 --- a/core/src/main/java/org/springframework/security/access/expression/method/PostInvocationExpressionAttribute.java +++ b/core/src/main/java/org/springframework/security/access/expression/method/PostInvocationExpressionAttribute.java @@ -7,7 +7,6 @@ import org.springframework.security.access.prepost.PostInvocationAttribute; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ class PostInvocationExpressionAttribute extends AbstractExpressionBasedMethodConfigAttribute diff --git a/core/src/main/java/org/springframework/security/access/expression/method/PreInvocationExpressionAttribute.java b/core/src/main/java/org/springframework/security/access/expression/method/PreInvocationExpressionAttribute.java index 2a1b964a08..6728e133ae 100644 --- a/core/src/main/java/org/springframework/security/access/expression/method/PreInvocationExpressionAttribute.java +++ b/core/src/main/java/org/springframework/security/access/expression/method/PreInvocationExpressionAttribute.java @@ -7,7 +7,6 @@ import org.springframework.security.access.prepost.PreInvocationAttribute; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ class PreInvocationExpressionAttribute extends AbstractExpressionBasedMethodConfigAttribute diff --git a/core/src/main/java/org/springframework/security/access/hierarchicalroles/CycleInRoleHierarchyException.java b/core/src/main/java/org/springframework/security/access/hierarchicalroles/CycleInRoleHierarchyException.java index 3e1588d10a..663d1e6572 100755 --- a/core/src/main/java/org/springframework/security/access/hierarchicalroles/CycleInRoleHierarchyException.java +++ b/core/src/main/java/org/springframework/security/access/hierarchicalroles/CycleInRoleHierarchyException.java @@ -1,30 +1,30 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.access.hierarchicalroles; - -/** - * Exception that is thrown because of a cycle in the role hierarchy definition - * - * @author Michael Mayr - */ -public class CycleInRoleHierarchyException extends RuntimeException { - - private static final long serialVersionUID = -4970510612118296707L; - - public CycleInRoleHierarchyException() { - super("Exception thrown because of a cycle in the role hierarchy definition!"); - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.access.hierarchicalroles; + +/** + * Exception that is thrown because of a cycle in the role hierarchy definition + * + * @author Michael Mayr + */ +public class CycleInRoleHierarchyException extends RuntimeException { + + private static final long serialVersionUID = -4970510612118296707L; + + public CycleInRoleHierarchyException() { + super("Exception thrown because of a cycle in the role hierarchy definition!"); + } + +} diff --git a/core/src/main/java/org/springframework/security/access/hierarchicalroles/NullRoleHierarchy.java b/core/src/main/java/org/springframework/security/access/hierarchicalroles/NullRoleHierarchy.java index d75381aeda..84654cf548 100644 --- a/core/src/main/java/org/springframework/security/access/hierarchicalroles/NullRoleHierarchy.java +++ b/core/src/main/java/org/springframework/security/access/hierarchicalroles/NullRoleHierarchy.java @@ -7,7 +7,6 @@ import org.springframework.security.core.GrantedAuthority; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public final class NullRoleHierarchy implements RoleHierarchy { diff --git a/core/src/main/java/org/springframework/security/access/hierarchicalroles/RoleHierarchy.java b/core/src/main/java/org/springframework/security/access/hierarchicalroles/RoleHierarchy.java index e69d949d46..2dc14e29c8 100755 --- a/core/src/main/java/org/springframework/security/access/hierarchicalroles/RoleHierarchy.java +++ b/core/src/main/java/org/springframework/security/access/hierarchicalroles/RoleHierarchy.java @@ -1,45 +1,45 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.access.hierarchicalroles; - -import java.util.Collection; - -import org.springframework.security.core.GrantedAuthority; - -/** - * The simple interface of a role hierarchy. - * - * @author Michael Mayr - */ -public interface RoleHierarchy { - - /** - * Returns an array of all reachable authorities. - *

- * Reachable authorities are the directly assigned authorities plus all - * authorities that are (transitively) reachable from them in the role - * hierarchy. - *

- * Example:
- * Role hierarchy: ROLE_A > ROLE_B and ROLE_B > ROLE_C.
- * Directly assigned authority: ROLE_A.
- * Reachable authorities: ROLE_A, ROLE_B, ROLE_C. - * - * @param authorities - List of the directly assigned authorities. - * @return List of all reachable authorities given the assigned authorities. - */ - public Collection getReachableGrantedAuthorities(Collection authorities); - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.access.hierarchicalroles; + +import java.util.Collection; + +import org.springframework.security.core.GrantedAuthority; + +/** + * The simple interface of a role hierarchy. + * + * @author Michael Mayr + */ +public interface RoleHierarchy { + + /** + * Returns an array of all reachable authorities. + *

+ * Reachable authorities are the directly assigned authorities plus all + * authorities that are (transitively) reachable from them in the role + * hierarchy. + *

+ * Example:
+ * Role hierarchy: ROLE_A > ROLE_B and ROLE_B > ROLE_C.
+ * Directly assigned authority: ROLE_A.
+ * Reachable authorities: ROLE_A, ROLE_B, ROLE_C. + * + * @param authorities - List of the directly assigned authorities. + * @return List of all reachable authorities given the assigned authorities. + */ + public Collection getReachableGrantedAuthorities(Collection authorities); + +} diff --git a/core/src/main/java/org/springframework/security/access/hierarchicalroles/UserDetailsServiceWrapper.java b/core/src/main/java/org/springframework/security/access/hierarchicalroles/UserDetailsServiceWrapper.java index 033589b8a5..7f2f523358 100755 --- a/core/src/main/java/org/springframework/security/access/hierarchicalroles/UserDetailsServiceWrapper.java +++ b/core/src/main/java/org/springframework/security/access/hierarchicalroles/UserDetailsServiceWrapper.java @@ -1,55 +1,55 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.access.hierarchicalroles; - -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.dao.DataAccessException; - -/** - * This class wraps Spring Security's UserDetailsService in a way that its loadUserByUsername() - * method returns wrapped UserDetails that return all hierachically reachable authorities - * instead of only the directly assigned authorities. - * - * @author Michael Mayr - * @deprecated use a {@link RoleHierarchyVoter} instead of populating the user Authentication object - * with the additional authorities. - */ -public class UserDetailsServiceWrapper implements UserDetailsService { - - private UserDetailsService userDetailsService = null; - - private RoleHierarchy roleHierarchy = null; - - public void setRoleHierarchy(RoleHierarchy roleHierarchy) { - this.roleHierarchy = roleHierarchy; - } - - public void setUserDetailsService(UserDetailsService userDetailsService) { - this.userDetailsService = userDetailsService; - } - - public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { - UserDetails userDetails = userDetailsService.loadUserByUsername(username); - // wrapped UserDetailsService might throw UsernameNotFoundException or DataAccessException which will then bubble up - return new UserDetailsWrapper(userDetails, roleHierarchy); - } - - public UserDetailsService getWrappedUserDetailsService() { - return userDetailsService; - } - +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.access.hierarchicalroles; + +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.dao.DataAccessException; + +/** + * This class wraps Spring Security's UserDetailsService in a way that its loadUserByUsername() + * method returns wrapped UserDetails that return all hierachically reachable authorities + * instead of only the directly assigned authorities. + * + * @author Michael Mayr + * @deprecated use a {@link RoleHierarchyVoter} instead of populating the user Authentication object + * with the additional authorities. + */ +public class UserDetailsServiceWrapper implements UserDetailsService { + + private UserDetailsService userDetailsService = null; + + private RoleHierarchy roleHierarchy = null; + + public void setRoleHierarchy(RoleHierarchy roleHierarchy) { + this.roleHierarchy = roleHierarchy; + } + + public void setUserDetailsService(UserDetailsService userDetailsService) { + this.userDetailsService = userDetailsService; + } + + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { + UserDetails userDetails = userDetailsService.loadUserByUsername(username); + // wrapped UserDetailsService might throw UsernameNotFoundException or DataAccessException which will then bubble up + return new UserDetailsWrapper(userDetails, roleHierarchy); + } + + public UserDetailsService getWrappedUserDetailsService() { + return userDetailsService; + } + } \ No newline at end of file diff --git a/core/src/main/java/org/springframework/security/access/hierarchicalroles/UserDetailsWrapper.java b/core/src/main/java/org/springframework/security/access/hierarchicalroles/UserDetailsWrapper.java index aab45cbef1..939a12eb2b 100755 --- a/core/src/main/java/org/springframework/security/access/hierarchicalroles/UserDetailsWrapper.java +++ b/core/src/main/java/org/springframework/security/access/hierarchicalroles/UserDetailsWrapper.java @@ -1,76 +1,76 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.access.hierarchicalroles; - -import java.util.Collection; - -import org.springframework.security.access.vote.RoleHierarchyVoter; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -/** - * This class wraps Spring Security's UserDetails in a way that its getAuthorities() method is - * delegated to RoleHierarchy.getReachableGrantedAuthorities. All other methods are - * delegated to the UserDetails implementation. - * - * @author Michael Mayr - * @deprecated use a {@link RoleHierarchyVoter} instead. - */ -public class UserDetailsWrapper implements UserDetails { - - private static final long serialVersionUID = 1532428778390085311L; - - private UserDetails userDetails = null; - - private RoleHierarchy roleHierarchy = null; - - public UserDetailsWrapper(UserDetails userDetails, RoleHierarchy roleHierarchy) { - this.userDetails = userDetails; - this.roleHierarchy = roleHierarchy; - } - - public boolean isAccountNonExpired() { - return userDetails.isAccountNonExpired(); - } - - public boolean isAccountNonLocked() { - return userDetails.isAccountNonLocked(); - } - - public Collection getAuthorities() { - return roleHierarchy.getReachableGrantedAuthorities(userDetails.getAuthorities()); - } - - public boolean isCredentialsNonExpired() { - return userDetails.isCredentialsNonExpired(); - } - - public boolean isEnabled() { - return userDetails.isEnabled(); - } - - public String getPassword() { - return userDetails.getPassword(); - } - - public String getUsername() { - return userDetails.getUsername(); - } - - public UserDetails getUnwrappedUserDetails() { - return userDetails; - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.access.hierarchicalroles; + +import java.util.Collection; + +import org.springframework.security.access.vote.RoleHierarchyVoter; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; + +/** + * This class wraps Spring Security's UserDetails in a way that its getAuthorities() method is + * delegated to RoleHierarchy.getReachableGrantedAuthorities. All other methods are + * delegated to the UserDetails implementation. + * + * @author Michael Mayr + * @deprecated use a {@link RoleHierarchyVoter} instead. + */ +public class UserDetailsWrapper implements UserDetails { + + private static final long serialVersionUID = 1532428778390085311L; + + private UserDetails userDetails = null; + + private RoleHierarchy roleHierarchy = null; + + public UserDetailsWrapper(UserDetails userDetails, RoleHierarchy roleHierarchy) { + this.userDetails = userDetails; + this.roleHierarchy = roleHierarchy; + } + + public boolean isAccountNonExpired() { + return userDetails.isAccountNonExpired(); + } + + public boolean isAccountNonLocked() { + return userDetails.isAccountNonLocked(); + } + + public Collection getAuthorities() { + return roleHierarchy.getReachableGrantedAuthorities(userDetails.getAuthorities()); + } + + public boolean isCredentialsNonExpired() { + return userDetails.isCredentialsNonExpired(); + } + + public boolean isEnabled() { + return userDetails.isEnabled(); + } + + public String getPassword() { + return userDetails.getPassword(); + } + + public String getUsername() { + return userDetails.getUsername(); + } + + public UserDetails getUnwrappedUserDetails() { + return userDetails; + } + +} diff --git a/core/src/main/java/org/springframework/security/access/intercept/AbstractSecurityInterceptor.java b/core/src/main/java/org/springframework/security/access/intercept/AbstractSecurityInterceptor.java index 9614ecec38..e40172ac87 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/AbstractSecurityInterceptor.java +++ b/core/src/main/java/org/springframework/security/access/intercept/AbstractSecurityInterceptor.java @@ -90,7 +90,6 @@ import org.springframework.util.Assert; * * * @author Ben Alex - * @version $Id$ */ public abstract class AbstractSecurityInterceptor implements InitializingBean, ApplicationEventPublisherAware, MessageSourceAware { diff --git a/core/src/main/java/org/springframework/security/access/intercept/AfterInvocationManager.java b/core/src/main/java/org/springframework/security/access/intercept/AfterInvocationManager.java index 3bea2b0a85..f79fa2726f 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/AfterInvocationManager.java +++ b/core/src/main/java/org/springframework/security/access/intercept/AfterInvocationManager.java @@ -46,7 +46,6 @@ import org.springframework.security.core.Authentication; *

* * @author Ben Alex - * @version $Id$ */ public interface AfterInvocationManager { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/intercept/AfterInvocationProviderManager.java b/core/src/main/java/org/springframework/security/access/intercept/AfterInvocationProviderManager.java index 1d9d54a0d9..a11a8240ad 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/AfterInvocationProviderManager.java +++ b/core/src/main/java/org/springframework/security/access/intercept/AfterInvocationProviderManager.java @@ -41,7 +41,6 @@ import org.springframework.util.Assert; * object invocation did not include a configuration attribute a given provider is configured to respond to). * * @author Ben Alex - * @version $Id$ */ public class AfterInvocationProviderManager implements AfterInvocationManager, InitializingBean { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/intercept/InterceptorStatusToken.java b/core/src/main/java/org/springframework/security/access/intercept/InterceptorStatusToken.java index e33948f4f4..eef02d87f1 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/InterceptorStatusToken.java +++ b/core/src/main/java/org/springframework/security/access/intercept/InterceptorStatusToken.java @@ -29,7 +29,6 @@ import org.springframework.security.core.Authentication; * can tidy up correctly. * * @author Ben Alex - * @version $Id$ */ public class InterceptorStatusToken { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/intercept/MethodInvocationPrivilegeEvaluator.java b/core/src/main/java/org/springframework/security/access/intercept/MethodInvocationPrivilegeEvaluator.java index acf2a815f5..227fce3e8b 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/MethodInvocationPrivilegeEvaluator.java +++ b/core/src/main/java/org/springframework/security/access/intercept/MethodInvocationPrivilegeEvaluator.java @@ -37,7 +37,6 @@ import org.springframework.util.Assert; * allowed to at least attempt to invoke the method, irrespective of the "after" invocation handling.

* * @author Ben Alex - * @version $Id$ */ public class MethodInvocationPrivilegeEvaluator implements InitializingBean { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/intercept/NullRunAsManager.java b/core/src/main/java/org/springframework/security/access/intercept/NullRunAsManager.java index 40d09c9f06..0be87631b4 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/NullRunAsManager.java +++ b/core/src/main/java/org/springframework/security/access/intercept/NullRunAsManager.java @@ -27,7 +27,6 @@ import org.springframework.security.core.Authentication; * This class should be used if you do not require run-as authentication replacement functionality. * * @author Ben Alex - * @version $Id$ */ final class NullRunAsManager implements RunAsManager { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/intercept/RunAsManager.java b/core/src/main/java/org/springframework/security/access/intercept/RunAsManager.java index b0aa87906c..dbcbbe5eaa 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/RunAsManager.java +++ b/core/src/main/java/org/springframework/security/access/intercept/RunAsManager.java @@ -60,7 +60,6 @@ import org.springframework.security.core.Authentication; *

* * @author Ben Alex - * @version $Id$ */ public interface RunAsManager { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/intercept/RunAsManagerImpl.java b/core/src/main/java/org/springframework/security/access/intercept/RunAsManagerImpl.java index 9e7bf8a7dd..7706060bd0 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/RunAsManagerImpl.java +++ b/core/src/main/java/org/springframework/security/access/intercept/RunAsManagerImpl.java @@ -48,7 +48,6 @@ import org.springframework.util.Assert; * * @author Ben Alex * @author colin sampaleanu - * @version $Id$ */ public class RunAsManagerImpl implements RunAsManager, InitializingBean { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/intercept/RunAsUserToken.java b/core/src/main/java/org/springframework/security/access/intercept/RunAsUserToken.java index 379ef73805..c71fdc45d2 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/RunAsUserToken.java +++ b/core/src/main/java/org/springframework/security/access/intercept/RunAsUserToken.java @@ -27,7 +27,6 @@ import org.springframework.security.core.GrantedAuthority; * An immutable {@link org.springframework.security.core.Authentication} implementation that supports {@link RunAsManagerImpl}. * * @author Ben Alex - * @version $Id$ */ public class RunAsUserToken extends AbstractAuthenticationToken { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptor.java b/core/src/main/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptor.java index 4c962c4199..9705820494 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptor.java +++ b/core/src/main/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptor.java @@ -34,7 +34,6 @@ import org.aopalliance.intercept.MethodInvocation; * Refer to {@link AbstractSecurityInterceptor} for details on the workflow. * * @author Ben Alex - * @version $Id$ */ public class MethodSecurityInterceptor extends AbstractSecurityInterceptor implements MethodInterceptor { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityMetadataSourceAdvisor.java b/core/src/main/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityMetadataSourceAdvisor.java index c9a0265fbc..1c6ccc67ef 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityMetadataSourceAdvisor.java +++ b/core/src/main/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityMetadataSourceAdvisor.java @@ -45,7 +45,6 @@ import org.springframework.util.Assert; * Based on Spring's TransactionAttributeSourceAdvisor. * * @author Ben Alex - * @version $Id$ */ public class MethodSecurityMetadataSourceAdvisor extends AbstractPointcutAdvisor implements BeanFactoryAware { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJAnnotationCallback.java b/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJAnnotationCallback.java index 448824c3c5..6b46bd6de9 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJAnnotationCallback.java +++ b/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJAnnotationCallback.java @@ -6,7 +6,6 @@ package org.springframework.security.access.intercept.aspectj; * AspectJ processing to continue. * * @author Mike Wiesner - * @version $Id$ */ public interface AspectJAnnotationCallback { diff --git a/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJAnnotationSecurityInterceptor.java b/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJAnnotationSecurityInterceptor.java index 63cdcc54eb..5c193f1d8a 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJAnnotationSecurityInterceptor.java +++ b/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJAnnotationSecurityInterceptor.java @@ -11,7 +11,6 @@ import org.aspectj.lang.JoinPoint; * AspectJ interceptor that supports @Aspect notation. * * @author Mike Wiesner - * @version $Id$ */ public class AspectJAnnotationSecurityInterceptor extends AbstractSecurityInterceptor { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJCallback.java b/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJCallback.java index f73f8d3c64..c332bfb232 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJCallback.java +++ b/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJCallback.java @@ -22,7 +22,6 @@ package org.springframework.security.access.intercept.aspectj; * statement. * * @author Ben Alex - * @version $Id$ */ public interface AspectJCallback { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJSecurityInterceptor.java b/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJSecurityInterceptor.java index 3bd034493e..9348d4d7f1 100644 --- a/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJSecurityInterceptor.java +++ b/core/src/main/java/org/springframework/security/access/intercept/aspectj/AspectJSecurityInterceptor.java @@ -37,7 +37,6 @@ import org.aspectj.lang.JoinPoint; * Refer to {@link AbstractSecurityInterceptor} for details on the workflow. * * @author Ben Alex - * @version $Id$ */ public class AspectJSecurityInterceptor extends AbstractSecurityInterceptor { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/method/AbstractFallbackMethodSecurityMetadataSource.java b/core/src/main/java/org/springframework/security/access/method/AbstractFallbackMethodSecurityMetadataSource.java index 4d426acfb3..af21e87996 100644 --- a/core/src/main/java/org/springframework/security/access/method/AbstractFallbackMethodSecurityMetadataSource.java +++ b/core/src/main/java/org/springframework/security/access/method/AbstractFallbackMethodSecurityMetadataSource.java @@ -22,7 +22,6 @@ import org.springframework.util.ClassUtils; * * @author Ben Alex * @author Luke taylor - * @version $Id$ * @since 2.0 */ public abstract class AbstractFallbackMethodSecurityMetadataSource extends AbstractMethodSecurityMetadataSource { diff --git a/core/src/main/java/org/springframework/security/access/method/AbstractMethodSecurityMetadataSource.java b/core/src/main/java/org/springframework/security/access/method/AbstractMethodSecurityMetadataSource.java index dbd13139f1..1d377850e4 100644 --- a/core/src/main/java/org/springframework/security/access/method/AbstractMethodSecurityMetadataSource.java +++ b/core/src/main/java/org/springframework/security/access/method/AbstractMethodSecurityMetadataSource.java @@ -38,7 +38,6 @@ import java.util.Collection; * * @author Ben Alex * @author Luke Taylor - * @version $Id$ */ public abstract class AbstractMethodSecurityMetadataSource implements MethodSecurityMetadataSource { diff --git a/core/src/main/java/org/springframework/security/access/method/DelegatingMethodSecurityMetadataSource.java b/core/src/main/java/org/springframework/security/access/method/DelegatingMethodSecurityMetadataSource.java index 8a8b27b733..f2aeeab073 100644 --- a/core/src/main/java/org/springframework/security/access/method/DelegatingMethodSecurityMetadataSource.java +++ b/core/src/main/java/org/springframework/security/access/method/DelegatingMethodSecurityMetadataSource.java @@ -20,7 +20,6 @@ import org.springframework.util.ObjectUtils; * * @author Ben Alex * @author Luke Taylor - * @version $Id$ */ public final class DelegatingMethodSecurityMetadataSource extends AbstractMethodSecurityMetadataSource implements InitializingBean { private final static List NULL_CONFIG_ATTRIBUTE = Collections.emptyList(); diff --git a/core/src/main/java/org/springframework/security/access/method/MapBasedMethodSecurityMetadataSource.java b/core/src/main/java/org/springframework/security/access/method/MapBasedMethodSecurityMetadataSource.java index 2021012a67..ea980a76ca 100644 --- a/core/src/main/java/org/springframework/security/access/method/MapBasedMethodSecurityMetadataSource.java +++ b/core/src/main/java/org/springframework/security/access/method/MapBasedMethodSecurityMetadataSource.java @@ -40,7 +40,6 @@ import org.springframework.util.ClassUtils; *

* * @author Ben Alex - * @version $Id$ * @since 2.0 */ public class MapBasedMethodSecurityMetadataSource extends AbstractFallbackMethodSecurityMetadataSource implements BeanClassLoaderAware { diff --git a/core/src/main/java/org/springframework/security/access/method/MethodSecurityMetadataSource.java b/core/src/main/java/org/springframework/security/access/method/MethodSecurityMetadataSource.java index 1f731528b9..b8308c3d01 100644 --- a/core/src/main/java/org/springframework/security/access/method/MethodSecurityMetadataSource.java +++ b/core/src/main/java/org/springframework/security/access/method/MethodSecurityMetadataSource.java @@ -27,7 +27,6 @@ import org.springframework.security.access.SecurityMetadataSource; * that are designed to perform lookups keyed on Methods. * * @author Ben Alex - * @version $Id$ */ public interface MethodSecurityMetadataSource extends SecurityMetadataSource { public Collection getAttributes(Method method, Class targetClass); diff --git a/core/src/main/java/org/springframework/security/access/method/MethodSecurityMetadataSourceEditor.java b/core/src/main/java/org/springframework/security/access/method/MethodSecurityMetadataSourceEditor.java index 69ce47bc76..7856ba8316 100644 --- a/core/src/main/java/org/springframework/security/access/method/MethodSecurityMetadataSourceEditor.java +++ b/core/src/main/java/org/springframework/security/access/method/MethodSecurityMetadataSourceEditor.java @@ -36,7 +36,6 @@ import org.springframework.util.StringUtils; * * @author Ben Alex * @deprecated use method annotations or the protect-pointcut support from the namespace - * @version $Id$ */ public class MethodSecurityMetadataSourceEditor extends PropertyEditorSupport { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/prepost/PostAuthorize.java b/core/src/main/java/org/springframework/security/access/prepost/PostAuthorize.java index 4833867749..6a698df580 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PostAuthorize.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PostAuthorize.java @@ -11,7 +11,6 @@ import java.lang.annotation.Target; * Annotation for specifying a method access-control expression which will be evaluated after a method has been invoked. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ @Target({ElementType.METHOD, ElementType.TYPE}) diff --git a/core/src/main/java/org/springframework/security/access/prepost/PostFilter.java b/core/src/main/java/org/springframework/security/access/prepost/PostFilter.java index 1db1dbbb02..7fe04dab55 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PostFilter.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PostFilter.java @@ -11,7 +11,6 @@ import java.lang.annotation.Target; * Annotation for specifying a method filtering expression which will be evaluated after a method has been invoked. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ @Target({ElementType.METHOD, ElementType.TYPE}) diff --git a/core/src/main/java/org/springframework/security/access/prepost/PostInvocationAdviceProvider.java b/core/src/main/java/org/springframework/security/access/prepost/PostInvocationAdviceProvider.java index 4c5436f4dd..88016b28bd 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PostInvocationAdviceProvider.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PostInvocationAdviceProvider.java @@ -15,7 +15,6 @@ import org.springframework.security.core.Authentication; * passing it the PostInvocationAttribute created from @PostAuthorize and @PostFilter annotations. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class PostInvocationAdviceProvider implements AfterInvocationProvider { diff --git a/core/src/main/java/org/springframework/security/access/prepost/PostInvocationAttribute.java b/core/src/main/java/org/springframework/security/access/prepost/PostInvocationAttribute.java index dd20b5b39f..9474f05533 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PostInvocationAttribute.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PostInvocationAttribute.java @@ -8,7 +8,6 @@ import org.springframework.security.access.ConfigAttribute; * Consumed by a {@link PostInvocationAuthorizationAdvice}. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface PostInvocationAttribute extends ConfigAttribute { diff --git a/core/src/main/java/org/springframework/security/access/prepost/PostInvocationAuthorizationAdvice.java b/core/src/main/java/org/springframework/security/access/prepost/PostInvocationAuthorizationAdvice.java index 663633fb55..e968bb8079 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PostInvocationAuthorizationAdvice.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PostInvocationAuthorizationAdvice.java @@ -9,7 +9,6 @@ import org.springframework.security.core.Authentication; * Performs filtering and authorization logic after a method is invoked. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface PostInvocationAuthorizationAdvice extends AopInfrastructureBean { diff --git a/core/src/main/java/org/springframework/security/access/prepost/PreAuthorize.java b/core/src/main/java/org/springframework/security/access/prepost/PreAuthorize.java index 32d3f1df0e..e9aec5943d 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PreAuthorize.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PreAuthorize.java @@ -12,7 +12,6 @@ import java.lang.annotation.Target; * method invocation is allowed or not. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ @Target({ElementType.METHOD, ElementType.TYPE}) diff --git a/core/src/main/java/org/springframework/security/access/prepost/PreFilter.java b/core/src/main/java/org/springframework/security/access/prepost/PreFilter.java index b15644892e..f156439b9f 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PreFilter.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PreFilter.java @@ -22,7 +22,6 @@ import java.lang.annotation.Target; * expression to refer to the current object which is being evaluated. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ @Target({ElementType.METHOD, ElementType.TYPE}) diff --git a/core/src/main/java/org/springframework/security/access/prepost/PreInvocationAttribute.java b/core/src/main/java/org/springframework/security/access/prepost/PreInvocationAttribute.java index 71551eb128..622695f45e 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PreInvocationAttribute.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PreInvocationAttribute.java @@ -8,7 +8,6 @@ import org.springframework.security.access.ConfigAttribute; * Consumed by a {@link PreInvocationAuthorizationAdvice}. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface PreInvocationAttribute extends ConfigAttribute{ diff --git a/core/src/main/java/org/springframework/security/access/prepost/PreInvocationAuthorizationAdvice.java b/core/src/main/java/org/springframework/security/access/prepost/PreInvocationAuthorizationAdvice.java index b4530359b7..490fac6e67 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PreInvocationAuthorizationAdvice.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PreInvocationAuthorizationAdvice.java @@ -8,7 +8,6 @@ import org.springframework.security.core.Authentication; * Performs argument filtering and authorization logic before a method is invoked. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface PreInvocationAuthorizationAdvice extends AopInfrastructureBean { diff --git a/core/src/main/java/org/springframework/security/access/prepost/PreInvocationAuthorizationAdviceVoter.java b/core/src/main/java/org/springframework/security/access/prepost/PreInvocationAuthorizationAdviceVoter.java index 6d114df16f..4904e9e46c 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PreInvocationAuthorizationAdviceVoter.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PreInvocationAuthorizationAdviceVoter.java @@ -19,7 +19,6 @@ import org.springframework.security.core.Authentication; * voter-based AccessDecisionManager implementations used by Spring Security. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class PreInvocationAuthorizationAdviceVoter implements AccessDecisionVoter { diff --git a/core/src/main/java/org/springframework/security/access/prepost/PrePostAnnotationSecurityMetadataSource.java b/core/src/main/java/org/springframework/security/access/prepost/PrePostAnnotationSecurityMetadataSource.java index 3e00a1d9b9..5138f5f25d 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PrePostAnnotationSecurityMetadataSource.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PrePostAnnotationSecurityMetadataSource.java @@ -27,7 +27,6 @@ import org.springframework.util.ClassUtils; * * @author Luke Taylor * @since 3.0 - * @version $Id$ */ public class PrePostAnnotationSecurityMetadataSource extends AbstractMethodSecurityMetadataSource { diff --git a/core/src/main/java/org/springframework/security/access/prepost/PrePostInvocationAttributeFactory.java b/core/src/main/java/org/springframework/security/access/prepost/PrePostInvocationAttributeFactory.java index c059acbc8e..5c34e03dec 100644 --- a/core/src/main/java/org/springframework/security/access/prepost/PrePostInvocationAttributeFactory.java +++ b/core/src/main/java/org/springframework/security/access/prepost/PrePostInvocationAttributeFactory.java @@ -5,7 +5,6 @@ import org.springframework.aop.framework.AopInfrastructureBean; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface PrePostInvocationAttributeFactory extends AopInfrastructureBean { diff --git a/core/src/main/java/org/springframework/security/access/vote/AbstractAclVoter.java b/core/src/main/java/org/springframework/security/access/vote/AbstractAclVoter.java index b7890f31a8..16cd0fcacc 100644 --- a/core/src/main/java/org/springframework/security/access/vote/AbstractAclVoter.java +++ b/core/src/main/java/org/springframework/security/access/vote/AbstractAclVoter.java @@ -30,7 +30,6 @@ import org.springframework.util.Assert; * Not bound to any particular ACL system. * * @author Ben Alex - * @version $Id$ */ public abstract class AbstractAclVoter implements AccessDecisionVoter { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/vote/AuthenticatedVoter.java b/core/src/main/java/org/springframework/security/access/vote/AuthenticatedVoter.java index db2d8e55df..d4ea93d8b9 100644 --- a/core/src/main/java/org/springframework/security/access/vote/AuthenticatedVoter.java +++ b/core/src/main/java/org/springframework/security/access/vote/AuthenticatedVoter.java @@ -40,7 +40,6 @@ import org.springframework.util.Assert; * All comparisons and prefixes are case sensitive. * * @author Ben Alex - * @version $Id$ */ public class AuthenticatedVoter implements AccessDecisionVoter { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/vote/InterfaceBasedLabelParameterStrategy.java b/core/src/main/java/org/springframework/security/access/vote/InterfaceBasedLabelParameterStrategy.java index fd05070c32..6dca070554 100644 --- a/core/src/main/java/org/springframework/security/access/vote/InterfaceBasedLabelParameterStrategy.java +++ b/core/src/main/java/org/springframework/security/access/vote/InterfaceBasedLabelParameterStrategy.java @@ -24,7 +24,6 @@ import java.lang.reflect.Method; * or retrieval of the label. * * @author Greg Turnquist - * @version $Id$ */ public class InterfaceBasedLabelParameterStrategy implements LabelParameterStrategy { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/access/vote/LabelBasedAclVoter.java b/core/src/main/java/org/springframework/security/access/vote/LabelBasedAclVoter.java index eb58c47bb1..71fbcfaaee 100644 --- a/core/src/main/java/org/springframework/security/access/vote/LabelBasedAclVoter.java +++ b/core/src/main/java/org/springframework/security/access/vote/LabelBasedAclVoter.java @@ -43,7 +43,6 @@ import org.springframework.util.Assert; * by setting up the labelMap in the application context.

* * @author Greg Turnquist - * @version $Id$ * * @see org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor * @deprecated Use new spring-security-acl module instead diff --git a/core/src/main/java/org/springframework/security/access/vote/LabelParameterStrategy.java b/core/src/main/java/org/springframework/security/access/vote/LabelParameterStrategy.java index 6640654175..531574f5a9 100644 --- a/core/src/main/java/org/springframework/security/access/vote/LabelParameterStrategy.java +++ b/core/src/main/java/org/springframework/security/access/vote/LabelParameterStrategy.java @@ -23,7 +23,6 @@ import java.lang.reflect.Method; * mechanism to define various ways to label data. * * @author Greg Turnquist - * @version $Id$ */ public interface LabelParameterStrategy { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/access/vote/RoleVoter.java b/core/src/main/java/org/springframework/security/access/vote/RoleVoter.java index e7c629c2b7..5f3b16558b 100644 --- a/core/src/main/java/org/springframework/security/access/vote/RoleVoter.java +++ b/core/src/main/java/org/springframework/security/access/vote/RoleVoter.java @@ -48,7 +48,6 @@ import org.springframework.security.core.GrantedAuthority; * * @author Ben Alex * @author colin sampaleanu - * @version $Id$ */ public class RoleVoter implements AccessDecisionVoter { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationManager.java b/core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationManager.java index 55fe54b088..5574ebb7c4 100644 --- a/core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationManager.java +++ b/core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationManager.java @@ -22,7 +22,6 @@ import org.springframework.security.core.AuthenticationException; * An abstract implementation of the {@link AuthenticationManager}. * * @author Wesley Hall - * @version $Id$ */ public abstract class AbstractAuthenticationManager implements AuthenticationManager { @@ -77,7 +76,7 @@ public abstract class AbstractAuthenticationManager implements AuthenticationMan * before rethrowing it. This is useful for use with remoting protocols where the information shouldn't * be serialized to the client. Defaults to 'false'. * - * @see org.springframework.security.core.AuthenticationException#getExtraInformation() + * @see org.springframework.security.core.AuthenticationException#getExtraInformation() */ public void setClearExtraInformation(boolean clearExtraInformation) { this.clearExtraInformation = clearExtraInformation; diff --git a/core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationToken.java b/core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationToken.java index 54cdfa1dd8..c4e675a4ac 100644 --- a/core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationToken.java +++ b/core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationToken.java @@ -33,7 +33,6 @@ import org.springframework.security.core.userdetails.UserDetails; * * @author Ben Alex * @author Luke Taylor - * @version $Id$ */ public abstract class AbstractAuthenticationToken implements Authentication { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/AccountExpiredException.java b/core/src/main/java/org/springframework/security/authentication/AccountExpiredException.java index a7f9180b9e..2ff17457fa 100644 --- a/core/src/main/java/org/springframework/security/authentication/AccountExpiredException.java +++ b/core/src/main/java/org/springframework/security/authentication/AccountExpiredException.java @@ -20,7 +20,6 @@ package org.springframework.security.authentication; * whether or not the credentials were valid. * * @author Ben Alex - * @version $Id$ */ public class AccountExpiredException extends AccountStatusException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/AccountStatusException.java b/core/src/main/java/org/springframework/security/authentication/AccountStatusException.java index c0237d1563..bf3e1d9955 100644 --- a/core/src/main/java/org/springframework/security/authentication/AccountStatusException.java +++ b/core/src/main/java/org/springframework/security/authentication/AccountStatusException.java @@ -7,7 +7,6 @@ import org.springframework.security.core.AuthenticationException; * user account status (locked, disabled etc). * * @author Luke Taylor - * @version $Id$ */ public abstract class AccountStatusException extends AuthenticationException { public AccountStatusException(String msg) { diff --git a/core/src/main/java/org/springframework/security/authentication/AccountStatusUserDetailsChecker.java b/core/src/main/java/org/springframework/security/authentication/AccountStatusUserDetailsChecker.java index be960d03f1..6801edcc7b 100644 --- a/core/src/main/java/org/springframework/security/authentication/AccountStatusUserDetailsChecker.java +++ b/core/src/main/java/org/springframework/security/authentication/AccountStatusUserDetailsChecker.java @@ -7,7 +7,6 @@ import org.springframework.context.support.MessageSourceAccessor; /** * @author Luke Taylor - * @version $Id$ */ public class AccountStatusUserDetailsChecker implements UserDetailsChecker { diff --git a/core/src/main/java/org/springframework/security/authentication/AnonymousAuthenticationProvider.java b/core/src/main/java/org/springframework/security/authentication/AnonymousAuthenticationProvider.java index e5156726d4..f385bb2aa5 100644 --- a/core/src/main/java/org/springframework/security/authentication/AnonymousAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/authentication/AnonymousAuthenticationProvider.java @@ -32,7 +32,6 @@ import org.springframework.util.Assert; * {@link #getKey()}. * * @author Ben Alex - * @version $Id$ */ public class AnonymousAuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware { diff --git a/core/src/main/java/org/springframework/security/authentication/AnonymousAuthenticationToken.java b/core/src/main/java/org/springframework/security/authentication/AnonymousAuthenticationToken.java index 6e7dc0053d..6d42b33ba2 100644 --- a/core/src/main/java/org/springframework/security/authentication/AnonymousAuthenticationToken.java +++ b/core/src/main/java/org/springframework/security/authentication/AnonymousAuthenticationToken.java @@ -27,7 +27,6 @@ import java.util.List; * Represents an anonymous Authentication. * * @author Ben Alex - * @version $Id$ */ public class AnonymousAuthenticationToken extends AbstractAuthenticationToken implements Serializable { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/AuthenticationCredentialsNotFoundException.java b/core/src/main/java/org/springframework/security/authentication/AuthenticationCredentialsNotFoundException.java index 24514c432a..44b9bea223 100644 --- a/core/src/main/java/org/springframework/security/authentication/AuthenticationCredentialsNotFoundException.java +++ b/core/src/main/java/org/springframework/security/authentication/AuthenticationCredentialsNotFoundException.java @@ -23,7 +23,6 @@ import org.springframework.security.core.AuthenticationException; * org.springframework.security.core.context.SecurityContext SecurityContext}. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationCredentialsNotFoundException extends AuthenticationException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/AuthenticationDetailsSource.java b/core/src/main/java/org/springframework/security/authentication/AuthenticationDetailsSource.java index f879713545..0b01c41f37 100644 --- a/core/src/main/java/org/springframework/security/authentication/AuthenticationDetailsSource.java +++ b/core/src/main/java/org/springframework/security/authentication/AuthenticationDetailsSource.java @@ -1,36 +1,35 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.authentication; - -/** - * Provides a {@link org.springframework.security.core.Authentication#getDetails()} object for - * a given web request. - * - * @author Ben Alex - * @version $Id$ - */ -public interface AuthenticationDetailsSource { - //~ Methods ======================================================================================================== - - /** - * Called by a class when it wishes a new authentication details instance to be created. - * - * @param context the request object, which may be used by the authentication details object - * - * @return a fully-configured authentication details instance - */ - Object buildDetails(Object context); -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.authentication; + +/** + * Provides a {@link org.springframework.security.core.Authentication#getDetails()} object for + * a given web request. + * + * @author Ben Alex + */ +public interface AuthenticationDetailsSource { + //~ Methods ======================================================================================================== + + /** + * Called by a class when it wishes a new authentication details instance to be created. + * + * @param context the request object, which may be used by the authentication details object + * + * @return a fully-configured authentication details instance + */ + Object buildDetails(Object context); +} diff --git a/core/src/main/java/org/springframework/security/authentication/AuthenticationEventPublisher.java b/core/src/main/java/org/springframework/security/authentication/AuthenticationEventPublisher.java index dada6df42e..b6e630c67e 100644 --- a/core/src/main/java/org/springframework/security/authentication/AuthenticationEventPublisher.java +++ b/core/src/main/java/org/springframework/security/authentication/AuthenticationEventPublisher.java @@ -6,7 +6,6 @@ import org.springframework.security.core.AuthenticationException; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface AuthenticationEventPublisher { diff --git a/core/src/main/java/org/springframework/security/authentication/AuthenticationManager.java b/core/src/main/java/org/springframework/security/authentication/AuthenticationManager.java index 6ed7cab4c8..06c4b8f2f9 100644 --- a/core/src/main/java/org/springframework/security/authentication/AuthenticationManager.java +++ b/core/src/main/java/org/springframework/security/authentication/AuthenticationManager.java @@ -22,7 +22,6 @@ import org.springframework.security.core.AuthenticationException; * Processes an {@link Authentication} request. * * @author Ben Alex - * @version $Id$ */ public interface AuthenticationManager { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/AuthenticationProvider.java b/core/src/main/java/org/springframework/security/authentication/AuthenticationProvider.java index 455f650de7..2186903af9 100644 --- a/core/src/main/java/org/springframework/security/authentication/AuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/authentication/AuthenticationProvider.java @@ -24,7 +24,6 @@ import org.springframework.security.core.AuthenticationException; * org.springframework.security.core.Authentication} implementation. * * @author Ben Alex - * @version $Id$ */ public interface AuthenticationProvider { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/AuthenticationServiceException.java b/core/src/main/java/org/springframework/security/authentication/AuthenticationServiceException.java index c07ae4f5ac..b44f67a997 100644 --- a/core/src/main/java/org/springframework/security/authentication/AuthenticationServiceException.java +++ b/core/src/main/java/org/springframework/security/authentication/AuthenticationServiceException.java @@ -22,7 +22,6 @@ import org.springframework.security.core.AuthenticationException; * backend authentication repository is unavailable.

* * @author Ben Alex - * @version $Id$ */ public class AuthenticationServiceException extends AuthenticationException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/AuthenticationTrustResolver.java b/core/src/main/java/org/springframework/security/authentication/AuthenticationTrustResolver.java index bc85d6e406..d680a343e5 100644 --- a/core/src/main/java/org/springframework/security/authentication/AuthenticationTrustResolver.java +++ b/core/src/main/java/org/springframework/security/authentication/AuthenticationTrustResolver.java @@ -21,7 +21,6 @@ import org.springframework.security.core.Authentication; * Evaluates Authentication tokens * * @author Ben Alex - * @version $Id$ */ public interface AuthenticationTrustResolver { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/AuthenticationTrustResolverImpl.java b/core/src/main/java/org/springframework/security/authentication/AuthenticationTrustResolverImpl.java index c37f69af28..8dc03cdfbf 100644 --- a/core/src/main/java/org/springframework/security/authentication/AuthenticationTrustResolverImpl.java +++ b/core/src/main/java/org/springframework/security/authentication/AuthenticationTrustResolverImpl.java @@ -27,7 +27,6 @@ import org.springframework.security.core.Authentication; * always return false. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationTrustResolverImpl implements AuthenticationTrustResolver { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/BadCredentialsException.java b/core/src/main/java/org/springframework/security/authentication/BadCredentialsException.java index 8ad0760593..7733942fa6 100644 --- a/core/src/main/java/org/springframework/security/authentication/BadCredentialsException.java +++ b/core/src/main/java/org/springframework/security/authentication/BadCredentialsException.java @@ -22,7 +22,6 @@ import org.springframework.security.core.AuthenticationException; * thrown, it means the account is neither locked nor disabled. * * @author Ben Alex - * @version $Id$ */ public class BadCredentialsException extends AuthenticationException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/CredentialsExpiredException.java b/core/src/main/java/org/springframework/security/authentication/CredentialsExpiredException.java index 145c3a4f7a..7972f504c0 100644 --- a/core/src/main/java/org/springframework/security/authentication/CredentialsExpiredException.java +++ b/core/src/main/java/org/springframework/security/authentication/CredentialsExpiredException.java @@ -20,7 +20,6 @@ package org.springframework.security.authentication; * assertion as to whether or not the credentials were valid. * * @author Ben Alex - * @version $Id$ */ public class CredentialsExpiredException extends AccountStatusException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/DefaultAuthenticationEventPublisher.java b/core/src/main/java/org/springframework/security/authentication/DefaultAuthenticationEventPublisher.java index addb297002..5a7a718640 100644 --- a/core/src/main/java/org/springframework/security/authentication/DefaultAuthenticationEventPublisher.java +++ b/core/src/main/java/org/springframework/security/authentication/DefaultAuthenticationEventPublisher.java @@ -37,7 +37,6 @@ import org.springframework.util.Assert; * and provides its constructor. The additionalExceptionMappings will be merged with the default ones. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class DefaultAuthenticationEventPublisher implements AuthenticationEventPublisher, diff --git a/core/src/main/java/org/springframework/security/authentication/DisabledException.java b/core/src/main/java/org/springframework/security/authentication/DisabledException.java index 6476a6678b..05648e221e 100644 --- a/core/src/main/java/org/springframework/security/authentication/DisabledException.java +++ b/core/src/main/java/org/springframework/security/authentication/DisabledException.java @@ -20,7 +20,6 @@ package org.springframework.security.authentication; * whether or not the credentials were valid. * * @author Ben Alex - * @version $Id$ */ public class DisabledException extends AccountStatusException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/InsufficientAuthenticationException.java b/core/src/main/java/org/springframework/security/authentication/InsufficientAuthenticationException.java index 2508bd66db..c0b36b25ed 100644 --- a/core/src/main/java/org/springframework/security/authentication/InsufficientAuthenticationException.java +++ b/core/src/main/java/org/springframework/security/authentication/InsufficientAuthenticationException.java @@ -28,7 +28,6 @@ import org.springframework.security.core.AuthenticationException; * level of authentication.

* * @author Ben Alex - * @version $Id$ */ public class InsufficientAuthenticationException extends AuthenticationException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/LockedException.java b/core/src/main/java/org/springframework/security/authentication/LockedException.java index aedf5c362c..cc8e5821e5 100644 --- a/core/src/main/java/org/springframework/security/authentication/LockedException.java +++ b/core/src/main/java/org/springframework/security/authentication/LockedException.java @@ -21,7 +21,6 @@ package org.springframework.security.authentication; * or not the credentials were valid. * * @author Ben Alex - * @version $Id$ */ public class LockedException extends AccountStatusException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/ProviderManager.java b/core/src/main/java/org/springframework/security/authentication/ProviderManager.java index c96d35f2aa..9117bb1109 100644 --- a/core/src/main/java/org/springframework/security/authentication/ProviderManager.java +++ b/core/src/main/java/org/springframework/security/authentication/ProviderManager.java @@ -62,7 +62,6 @@ import org.springframework.util.Assert; * * @author Ben Alex * @author Luke Taylor - * @version $Id$ * * @see DefaultAuthenticationEventPublisher */ diff --git a/core/src/main/java/org/springframework/security/authentication/ProviderNotFoundException.java b/core/src/main/java/org/springframework/security/authentication/ProviderNotFoundException.java index 872c9b00f9..305fffaef6 100644 --- a/core/src/main/java/org/springframework/security/authentication/ProviderNotFoundException.java +++ b/core/src/main/java/org/springframework/security/authentication/ProviderNotFoundException.java @@ -24,7 +24,6 @@ import org.springframework.security.core.AuthenticationException; * presented {@link org.springframework.security.core.Authentication} object. * * @author Ben Alex - * @version $Id$ */ public class ProviderNotFoundException extends AuthenticationException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/RememberMeAuthenticationToken.java b/core/src/main/java/org/springframework/security/authentication/RememberMeAuthenticationToken.java index 069ca11900..80dc6fa11b 100644 --- a/core/src/main/java/org/springframework/security/authentication/RememberMeAuthenticationToken.java +++ b/core/src/main/java/org/springframework/security/authentication/RememberMeAuthenticationToken.java @@ -28,7 +28,6 @@ import org.springframework.security.core.GrantedAuthority; * GrantedAuthoritys that apply. * * @author Ben Alex - * @version $Id$ */ public class RememberMeAuthenticationToken extends AbstractAuthenticationToken implements Serializable { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/TestingAuthenticationProvider.java b/core/src/main/java/org/springframework/security/authentication/TestingAuthenticationProvider.java index ae118e5bc4..3db3400e57 100644 --- a/core/src/main/java/org/springframework/security/authentication/TestingAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/authentication/TestingAuthenticationProvider.java @@ -27,7 +27,6 @@ import org.springframework.security.core.AuthenticationException; * on a production system. * * @author Ben Alex - * @version $Id$ */ public class TestingAuthenticationProvider implements AuthenticationProvider { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/TestingAuthenticationToken.java b/core/src/main/java/org/springframework/security/authentication/TestingAuthenticationToken.java index f2d1b035dd..ba50e6d0ba 100644 --- a/core/src/main/java/org/springframework/security/authentication/TestingAuthenticationToken.java +++ b/core/src/main/java/org/springframework/security/authentication/TestingAuthenticationToken.java @@ -28,7 +28,6 @@ import org.springframework.security.core.authority.AuthorityUtils; * The corresponding authentication provider is {@link TestingAuthenticationProvider}. * * @author Ben Alex - * @version $Id$ */ public class TestingAuthenticationToken extends AbstractAuthenticationToken { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/UsernamePasswordAuthenticationToken.java b/core/src/main/java/org/springframework/security/authentication/UsernamePasswordAuthenticationToken.java index e2f4353ed9..a887d9af0e 100644 --- a/core/src/main/java/org/springframework/security/authentication/UsernamePasswordAuthenticationToken.java +++ b/core/src/main/java/org/springframework/security/authentication/UsernamePasswordAuthenticationToken.java @@ -30,7 +30,6 @@ import org.springframework.security.core.GrantedAuthority; * is String. * * @author Ben Alex - * @version $Id$ */ public class UsernamePasswordAuthenticationToken extends AbstractAuthenticationToken { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java b/core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java index c35ba2b934..966d1781cc 100644 --- a/core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java @@ -68,7 +68,6 @@ import org.springframework.util.Assert; * each request. The default cache implementation is therefore {@link NullUserCache}. * * @author Ben Alex - * @version $Id$ */ public abstract class AbstractUserDetailsAuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware { diff --git a/core/src/main/java/org/springframework/security/authentication/dao/DaoAuthenticationProvider.java b/core/src/main/java/org/springframework/security/authentication/dao/DaoAuthenticationProvider.java index 23b1b5f310..c713d77e8f 100644 --- a/core/src/main/java/org/springframework/security/authentication/dao/DaoAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/authentication/dao/DaoAuthenticationProvider.java @@ -32,7 +32,6 @@ import org.springframework.util.Assert; * from an {@link UserDetailsService}. * * @author Ben Alex - * @version $Id$ */ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider { diff --git a/core/src/main/java/org/springframework/security/authentication/dao/ReflectionSaltSource.java b/core/src/main/java/org/springframework/security/authentication/dao/ReflectionSaltSource.java index b48b24be44..679dc71023 100644 --- a/core/src/main/java/org/springframework/security/authentication/dao/ReflectionSaltSource.java +++ b/core/src/main/java/org/springframework/security/authentication/dao/ReflectionSaltSource.java @@ -37,7 +37,6 @@ import java.beans.PropertyDescriptor; * likely to change. * * @author Ben Alex - * @version $Id$ */ public class ReflectionSaltSource implements SaltSource, InitializingBean { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/dao/SaltSource.java b/core/src/main/java/org/springframework/security/authentication/dao/SaltSource.java index b000b4a9f6..747b8b9f3d 100644 --- a/core/src/main/java/org/springframework/security/authentication/dao/SaltSource.java +++ b/core/src/main/java/org/springframework/security/authentication/dao/SaltSource.java @@ -22,7 +22,6 @@ import org.springframework.security.core.userdetails.UserDetails; * Provides alternative sources of the salt to use for encoding passwords. * * @author Ben Alex - * @version $Id$ */ public interface SaltSource { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/dao/SystemWideSaltSource.java b/core/src/main/java/org/springframework/security/authentication/dao/SystemWideSaltSource.java index d29fa9b311..417ca97f06 100644 --- a/core/src/main/java/org/springframework/security/authentication/dao/SystemWideSaltSource.java +++ b/core/src/main/java/org/springframework/security/authentication/dao/SystemWideSaltSource.java @@ -27,7 +27,6 @@ import org.springframework.beans.factory.InitializingBean; * password. Of benefit is the digested passwords will at least be more protected than if stored without any salt.

* * @author Ben Alex - * @version $Id$ */ public class SystemWideSaltSource implements SaltSource, InitializingBean { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/encoding/BaseDigestPasswordEncoder.java b/core/src/main/java/org/springframework/security/authentication/encoding/BaseDigestPasswordEncoder.java index 7c43e19785..bb0921f3cf 100644 --- a/core/src/main/java/org/springframework/security/authentication/encoding/BaseDigestPasswordEncoder.java +++ b/core/src/main/java/org/springframework/security/authentication/encoding/BaseDigestPasswordEncoder.java @@ -19,7 +19,6 @@ package org.springframework.security.authentication.encoding; *

Convenience base for digest password encoders.

* * @author colin sampaleanu - * @version $Id$ */ public abstract class BaseDigestPasswordEncoder extends BasePasswordEncoder { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/encoding/BasePasswordEncoder.java b/core/src/main/java/org/springframework/security/authentication/encoding/BasePasswordEncoder.java index 9d94126f5d..add0da8792 100644 --- a/core/src/main/java/org/springframework/security/authentication/encoding/BasePasswordEncoder.java +++ b/core/src/main/java/org/springframework/security/authentication/encoding/BasePasswordEncoder.java @@ -19,7 +19,6 @@ package org.springframework.security.authentication.encoding; *

Convenience base for all password encoders.

* * @author Ben Alex - * @version $Id$ */ public abstract class BasePasswordEncoder implements PasswordEncoder { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/encoding/LdapShaPasswordEncoder.java b/core/src/main/java/org/springframework/security/authentication/encoding/LdapShaPasswordEncoder.java index 695931acb1..fbe5eed42d 100644 --- a/core/src/main/java/org/springframework/security/authentication/encoding/LdapShaPasswordEncoder.java +++ b/core/src/main/java/org/springframework/security/authentication/encoding/LdapShaPasswordEncoder.java @@ -32,7 +32,6 @@ import org.springframework.util.Assert; * use or when a null implementation is required. * * @author Luke Taylor - * @version $Id$ */ public class LdapShaPasswordEncoder implements PasswordEncoder { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/encoding/Md4.java b/core/src/main/java/org/springframework/security/authentication/encoding/Md4.java index ad8ab5750f..bab8c0c751 100644 --- a/core/src/main/java/org/springframework/security/authentication/encoding/Md4.java +++ b/core/src/main/java/org/springframework/security/authentication/encoding/Md4.java @@ -1,179 +1,179 @@ -/* Copyright 2004, 2005, 2006, 2007 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.security.authentication.encoding; - -/** - * Implementation of the MD4 message digest derived from the RSA Data Security, Inc, MD4 Message-Digest Algorithm. - * - * @author Alan Stewart - */ -class Md4 { - private static final int BLOCK_SIZE = 64; - private static final int HASH_SIZE = 16; - private final byte[] buffer = new byte[BLOCK_SIZE]; - private int bufferOffset; - private long byteCount; - private int[] state = new int[4]; - private int[] tmp = new int[16]; - - Md4() { - reset(); - } - - public void reset() { - bufferOffset = 0; - byteCount = 0; - state[0] = 0x67452301; - state[1] = 0xEFCDAB89; - state[2] = 0x98BADCFE; - state[3] = 0x10325476; - } - - public byte[] digest() { - byte[] resBuf = new byte[HASH_SIZE]; - digest(resBuf, 0, HASH_SIZE); - return resBuf; - } - - private void digest(byte[] buffer, int off) { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - buffer[off + (i * 4 + j)] = (byte) (state[i] >>> (8 * j)); - } - } - } - - private void digest(byte[] buffer, int offset, int len) { - this.buffer[this.bufferOffset++] = (byte) 0x80; - int lenOfBitLen = 8; - int C = BLOCK_SIZE - lenOfBitLen; - if (this.bufferOffset > C) { - while (this.bufferOffset < BLOCK_SIZE) { - this.buffer[this.bufferOffset++] = (byte) 0x00; - } - update(this.buffer, 0); - this.bufferOffset = 0; - } - - while (this.bufferOffset < C) { - this.buffer[this.bufferOffset++] = (byte) 0x00; - } - - long bitCount = byteCount * 8; - for (int i = 0; i < 64; i += 8) { - this.buffer[this.bufferOffset++] = (byte) (bitCount >>> (i)); - } - - update(this.buffer, 0); - digest(buffer, offset); - } - - public void update(byte[] input, int offset, int length) { - byteCount += length; - int todo; - while (length >= (todo = BLOCK_SIZE - this.bufferOffset)) { - System.arraycopy(input, offset, this.buffer, this.bufferOffset, todo); - update(this.buffer, 0); - length -= todo; - offset += todo; - this.bufferOffset = 0; - } - - System.arraycopy(input, offset, this.buffer, this.bufferOffset, length); - bufferOffset += length; - } - - private void update(byte[] block, int offset) { - for (int i = 0; i < 16; i++) { - tmp[i] = (block[offset++] & 0xFF) | (block[offset++] & 0xFF) << 8 | (block[offset++] & 0xFF) << 16 | (block[offset++] & 0xFF) << 24; - } - - int A = state[0]; - int B = state[1]; - int C = state[2]; - int D = state[3]; - - A = FF(A, B, C, D, tmp[0], 3); - D = FF(D, A, B, C, tmp[1], 7); - C = FF(C, D, A, B, tmp[2], 11); - B = FF(B, C, D, A, tmp[3], 19); - A = FF(A, B, C, D, tmp[4], 3); - D = FF(D, A, B, C, tmp[5], 7); - C = FF(C, D, A, B, tmp[6], 11); - B = FF(B, C, D, A, tmp[7], 19); - A = FF(A, B, C, D, tmp[8], 3); - D = FF(D, A, B, C, tmp[9], 7); - C = FF(C, D, A, B, tmp[10], 11); - B = FF(B, C, D, A, tmp[11], 19); - A = FF(A, B, C, D, tmp[12], 3); - D = FF(D, A, B, C, tmp[13], 7); - C = FF(C, D, A, B, tmp[14], 11); - B = FF(B, C, D, A, tmp[15], 19); - - A = GG(A, B, C, D, tmp[0], 3); - D = GG(D, A, B, C, tmp[4], 5); - C = GG(C, D, A, B, tmp[8], 9); - B = GG(B, C, D, A, tmp[12], 13); - A = GG(A, B, C, D, tmp[1], 3); - D = GG(D, A, B, C, tmp[5], 5); - C = GG(C, D, A, B, tmp[9], 9); - B = GG(B, C, D, A, tmp[13], 13); - A = GG(A, B, C, D, tmp[2], 3); - D = GG(D, A, B, C, tmp[6], 5); - C = GG(C, D, A, B, tmp[10], 9); - B = GG(B, C, D, A, tmp[14], 13); - A = GG(A, B, C, D, tmp[3], 3); - D = GG(D, A, B, C, tmp[7], 5); - C = GG(C, D, A, B, tmp[11], 9); - B = GG(B, C, D, A, tmp[15], 13); - - A = HH(A, B, C, D, tmp[0], 3); - D = HH(D, A, B, C, tmp[8], 9); - C = HH(C, D, A, B, tmp[4], 11); - B = HH(B, C, D, A, tmp[12], 15); - A = HH(A, B, C, D, tmp[2], 3); - D = HH(D, A, B, C, tmp[10], 9); - C = HH(C, D, A, B, tmp[6], 11); - B = HH(B, C, D, A, tmp[14], 15); - A = HH(A, B, C, D, tmp[1], 3); - D = HH(D, A, B, C, tmp[9], 9); - C = HH(C, D, A, B, tmp[5], 11); - B = HH(B, C, D, A, tmp[13], 15); - A = HH(A, B, C, D, tmp[3], 3); - D = HH(D, A, B, C, tmp[11], 9); - C = HH(C, D, A, B, tmp[7], 11); - B = HH(B, C, D, A, tmp[15], 15); - - state[0] += A; - state[1] += B; - state[2] += C; - state[3] += D; - } - - private int FF(int a, int b, int c, int d, int x, int s) { - int t = a + ((b & c) | (~b & d)) + x; - return t << s | t >>> (32 - s); - } - - private int GG(int a, int b, int c, int d, int x, int s) { - int t = a + ((b & (c | d)) | (c & d)) + x + 0x5A827999; - return t << s | t >>> (32 - s); - } - - private int HH(int a, int b, int c, int d, int x, int s) { - int t = a + (b ^ c ^ d) + x + 0x6ED9EBA1; - return t << s | t >>> (32 - s); - } -} +/* Copyright 2004, 2005, 2006, 2007 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.security.authentication.encoding; + +/** + * Implementation of the MD4 message digest derived from the RSA Data Security, Inc, MD4 Message-Digest Algorithm. + * + * @author Alan Stewart + */ +class Md4 { + private static final int BLOCK_SIZE = 64; + private static final int HASH_SIZE = 16; + private final byte[] buffer = new byte[BLOCK_SIZE]; + private int bufferOffset; + private long byteCount; + private int[] state = new int[4]; + private int[] tmp = new int[16]; + + Md4() { + reset(); + } + + public void reset() { + bufferOffset = 0; + byteCount = 0; + state[0] = 0x67452301; + state[1] = 0xEFCDAB89; + state[2] = 0x98BADCFE; + state[3] = 0x10325476; + } + + public byte[] digest() { + byte[] resBuf = new byte[HASH_SIZE]; + digest(resBuf, 0, HASH_SIZE); + return resBuf; + } + + private void digest(byte[] buffer, int off) { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + buffer[off + (i * 4 + j)] = (byte) (state[i] >>> (8 * j)); + } + } + } + + private void digest(byte[] buffer, int offset, int len) { + this.buffer[this.bufferOffset++] = (byte) 0x80; + int lenOfBitLen = 8; + int C = BLOCK_SIZE - lenOfBitLen; + if (this.bufferOffset > C) { + while (this.bufferOffset < BLOCK_SIZE) { + this.buffer[this.bufferOffset++] = (byte) 0x00; + } + update(this.buffer, 0); + this.bufferOffset = 0; + } + + while (this.bufferOffset < C) { + this.buffer[this.bufferOffset++] = (byte) 0x00; + } + + long bitCount = byteCount * 8; + for (int i = 0; i < 64; i += 8) { + this.buffer[this.bufferOffset++] = (byte) (bitCount >>> (i)); + } + + update(this.buffer, 0); + digest(buffer, offset); + } + + public void update(byte[] input, int offset, int length) { + byteCount += length; + int todo; + while (length >= (todo = BLOCK_SIZE - this.bufferOffset)) { + System.arraycopy(input, offset, this.buffer, this.bufferOffset, todo); + update(this.buffer, 0); + length -= todo; + offset += todo; + this.bufferOffset = 0; + } + + System.arraycopy(input, offset, this.buffer, this.bufferOffset, length); + bufferOffset += length; + } + + private void update(byte[] block, int offset) { + for (int i = 0; i < 16; i++) { + tmp[i] = (block[offset++] & 0xFF) | (block[offset++] & 0xFF) << 8 | (block[offset++] & 0xFF) << 16 | (block[offset++] & 0xFF) << 24; + } + + int A = state[0]; + int B = state[1]; + int C = state[2]; + int D = state[3]; + + A = FF(A, B, C, D, tmp[0], 3); + D = FF(D, A, B, C, tmp[1], 7); + C = FF(C, D, A, B, tmp[2], 11); + B = FF(B, C, D, A, tmp[3], 19); + A = FF(A, B, C, D, tmp[4], 3); + D = FF(D, A, B, C, tmp[5], 7); + C = FF(C, D, A, B, tmp[6], 11); + B = FF(B, C, D, A, tmp[7], 19); + A = FF(A, B, C, D, tmp[8], 3); + D = FF(D, A, B, C, tmp[9], 7); + C = FF(C, D, A, B, tmp[10], 11); + B = FF(B, C, D, A, tmp[11], 19); + A = FF(A, B, C, D, tmp[12], 3); + D = FF(D, A, B, C, tmp[13], 7); + C = FF(C, D, A, B, tmp[14], 11); + B = FF(B, C, D, A, tmp[15], 19); + + A = GG(A, B, C, D, tmp[0], 3); + D = GG(D, A, B, C, tmp[4], 5); + C = GG(C, D, A, B, tmp[8], 9); + B = GG(B, C, D, A, tmp[12], 13); + A = GG(A, B, C, D, tmp[1], 3); + D = GG(D, A, B, C, tmp[5], 5); + C = GG(C, D, A, B, tmp[9], 9); + B = GG(B, C, D, A, tmp[13], 13); + A = GG(A, B, C, D, tmp[2], 3); + D = GG(D, A, B, C, tmp[6], 5); + C = GG(C, D, A, B, tmp[10], 9); + B = GG(B, C, D, A, tmp[14], 13); + A = GG(A, B, C, D, tmp[3], 3); + D = GG(D, A, B, C, tmp[7], 5); + C = GG(C, D, A, B, tmp[11], 9); + B = GG(B, C, D, A, tmp[15], 13); + + A = HH(A, B, C, D, tmp[0], 3); + D = HH(D, A, B, C, tmp[8], 9); + C = HH(C, D, A, B, tmp[4], 11); + B = HH(B, C, D, A, tmp[12], 15); + A = HH(A, B, C, D, tmp[2], 3); + D = HH(D, A, B, C, tmp[10], 9); + C = HH(C, D, A, B, tmp[6], 11); + B = HH(B, C, D, A, tmp[14], 15); + A = HH(A, B, C, D, tmp[1], 3); + D = HH(D, A, B, C, tmp[9], 9); + C = HH(C, D, A, B, tmp[5], 11); + B = HH(B, C, D, A, tmp[13], 15); + A = HH(A, B, C, D, tmp[3], 3); + D = HH(D, A, B, C, tmp[11], 9); + C = HH(C, D, A, B, tmp[7], 11); + B = HH(B, C, D, A, tmp[15], 15); + + state[0] += A; + state[1] += B; + state[2] += C; + state[3] += D; + } + + private int FF(int a, int b, int c, int d, int x, int s) { + int t = a + ((b & c) | (~b & d)) + x; + return t << s | t >>> (32 - s); + } + + private int GG(int a, int b, int c, int d, int x, int s) { + int t = a + ((b & (c | d)) | (c & d)) + x + 0x5A827999; + return t << s | t >>> (32 - s); + } + + private int HH(int a, int b, int c, int d, int x, int s) { + int t = a + (b ^ c ^ d) + x + 0x6ED9EBA1; + return t << s | t >>> (32 - s); + } +} diff --git a/core/src/main/java/org/springframework/security/authentication/encoding/Md4PasswordEncoder.java b/core/src/main/java/org/springframework/security/authentication/encoding/Md4PasswordEncoder.java index b9d99260c7..c9422c5373 100644 --- a/core/src/main/java/org/springframework/security/authentication/encoding/Md4PasswordEncoder.java +++ b/core/src/main/java/org/springframework/security/authentication/encoding/Md4PasswordEncoder.java @@ -1,87 +1,87 @@ -/* Copyright 2004, 2005, 2006, 2007 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.security.authentication.encoding; - -import java.io.UnsupportedEncodingException; - -import org.springframework.security.core.codec.Base64; -import org.springframework.security.core.codec.Hex; - -/** - * MD4 implementation of PasswordEncoder. - *

- * If a null password is presented, it will be treated as an empty String ("") password. - *

- * As MD4 is a one-way hash, the salt can contain any characters. - *

- * NOTE: This password encoder is only included for backwards compatability with legacy applications, it's not - * secure, don't use it for anything new! - * - * @author Alan Stewart - */ -public class Md4PasswordEncoder extends BaseDigestPasswordEncoder { - - //~ Methods ======================================================================================================== - - /** - * Encodes the rawPass using an MD4 message digest. If a salt is specified it will be merged with the password - * before encoding. - * - * @param rawPass The plain text password - * @param salt The salt to sprinkle - * @return Hex string of password digest (or base64 encoded string if encodeHashAsBase64 is enabled. - */ - public String encodePassword(String rawPass, Object salt) { - String saltedPass = mergePasswordAndSalt(rawPass, salt, false); - - byte[] passBytes; - - try { - passBytes = saltedPass.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new IllegalStateException("UTF-8 not supported!"); - } - - Md4 md4 = new Md4(); - md4.update(passBytes, 0, passBytes.length); - - byte[] resBuf = md4.digest(); - - if (getEncodeHashAsBase64()) { - return new String(Base64.encode(resBuf)); - } else { - return new String(Hex.encode(resBuf)); - } - } - - /** - * Takes a previously encoded password and compares it with a raw password after mixing in the salt and - * encoding that value. - * - * @param encPass previously encoded password - * @param rawPass plain text password - * @param salt salt to mix into password - * @return true or false - */ - public boolean isPasswordValid(String encPass, String rawPass, Object salt) { - String pass1 = "" + encPass; - String pass2 = encodePassword(rawPass, salt); - return pass1.equals(pass2); - } - - public String getAlgorithm() { - return "MD4"; - } -} +/* Copyright 2004, 2005, 2006, 2007 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.security.authentication.encoding; + +import java.io.UnsupportedEncodingException; + +import org.springframework.security.core.codec.Base64; +import org.springframework.security.core.codec.Hex; + +/** + * MD4 implementation of PasswordEncoder. + *

+ * If a null password is presented, it will be treated as an empty String ("") password. + *

+ * As MD4 is a one-way hash, the salt can contain any characters. + *

+ * NOTE: This password encoder is only included for backwards compatability with legacy applications, it's not + * secure, don't use it for anything new! + * + * @author Alan Stewart + */ +public class Md4PasswordEncoder extends BaseDigestPasswordEncoder { + + //~ Methods ======================================================================================================== + + /** + * Encodes the rawPass using an MD4 message digest. If a salt is specified it will be merged with the password + * before encoding. + * + * @param rawPass The plain text password + * @param salt The salt to sprinkle + * @return Hex string of password digest (or base64 encoded string if encodeHashAsBase64 is enabled. + */ + public String encodePassword(String rawPass, Object salt) { + String saltedPass = mergePasswordAndSalt(rawPass, salt, false); + + byte[] passBytes; + + try { + passBytes = saltedPass.getBytes("UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new IllegalStateException("UTF-8 not supported!"); + } + + Md4 md4 = new Md4(); + md4.update(passBytes, 0, passBytes.length); + + byte[] resBuf = md4.digest(); + + if (getEncodeHashAsBase64()) { + return new String(Base64.encode(resBuf)); + } else { + return new String(Hex.encode(resBuf)); + } + } + + /** + * Takes a previously encoded password and compares it with a raw password after mixing in the salt and + * encoding that value. + * + * @param encPass previously encoded password + * @param rawPass plain text password + * @param salt salt to mix into password + * @return true or false + */ + public boolean isPasswordValid(String encPass, String rawPass, Object salt) { + String pass1 = "" + encPass; + String pass2 = encodePassword(rawPass, salt); + return pass1.equals(pass2); + } + + public String getAlgorithm() { + return "MD4"; + } +} diff --git a/core/src/main/java/org/springframework/security/authentication/encoding/Md5PasswordEncoder.java b/core/src/main/java/org/springframework/security/authentication/encoding/Md5PasswordEncoder.java index 55f4ac67fd..ee57f00472 100644 --- a/core/src/main/java/org/springframework/security/authentication/encoding/Md5PasswordEncoder.java +++ b/core/src/main/java/org/springframework/security/authentication/encoding/Md5PasswordEncoder.java @@ -26,7 +26,6 @@ package org.springframework.security.authentication.encoding; * @author Ray Krueger * @author colin sampaleanu * @author Ben Alex - * @version $Id$ */ public class Md5PasswordEncoder extends MessageDigestPasswordEncoder { diff --git a/core/src/main/java/org/springframework/security/authentication/encoding/MessageDigestPasswordEncoder.java b/core/src/main/java/org/springframework/security/authentication/encoding/MessageDigestPasswordEncoder.java index 827e9ec24d..a306a19be9 100644 --- a/core/src/main/java/org/springframework/security/authentication/encoding/MessageDigestPasswordEncoder.java +++ b/core/src/main/java/org/springframework/security/authentication/encoding/MessageDigestPasswordEncoder.java @@ -1,125 +1,125 @@ -package org.springframework.security.authentication.encoding; - -import java.io.UnsupportedEncodingException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import org.springframework.security.core.codec.Base64; -import org.springframework.security.core.codec.Hex; - -/** - * Base for digest password encoders. - *

This class can be used stand-alone, or one of the subclasses can be used for compatiblity and convenience. - * When using this class directly you must specify a - * - * Message Digest Algorithm to use as a constructor arg

- * - *

The encoded password hash is normally returned as Hex (32 char) version of the hash bytes. - * Setting the encodeHashAsBase64 property to true will cause the encoded pass to be returned - * as Base64 text, which will consume 24 characters. - * See {@link BaseDigestPasswordEncoder#setEncodeHashAsBase64(boolean)} - *

- *

- * This PasswordEncoder can be used directly as in the following example:
- *

- * <bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder">
- *     <constructor-arg value="MD5"/>
- * </bean>
- * 
- *

- * - * @author Ray Krueger - * @since 1.0.1 - */ -public class MessageDigestPasswordEncoder extends BaseDigestPasswordEncoder { - - private final String algorithm; - - /** - * The digest algorithm to use - * Supports the named - * Message Digest Algorithms in the Java environment. - * - * @param algorithm - */ - public MessageDigestPasswordEncoder(String algorithm) { - this(algorithm, false); - } - - /** - * Convenience constructor for specifying the algorithm and whether or not to enable base64 encoding - * - * @param algorithm - * @param encodeHashAsBase64 - * @throws IllegalArgumentException if an unknown - */ - public MessageDigestPasswordEncoder(String algorithm, boolean encodeHashAsBase64) throws IllegalArgumentException { - this.algorithm = algorithm; - setEncodeHashAsBase64(encodeHashAsBase64); - //Validity Check - getMessageDigest(); - } - - /** - * Encodes the rawPass using a MessageDigest. - * If a salt is specified it will be merged with the password before encoding. - * - * @param rawPass The plain text password - * @param salt The salt to sprinkle - * @return Hex string of password digest (or base64 encoded string if encodeHashAsBase64 is enabled. - */ - public String encodePassword(String rawPass, Object salt) { - String saltedPass = mergePasswordAndSalt(rawPass, salt, false); - - MessageDigest messageDigest = getMessageDigest(); - - byte[] digest; - - try { - digest = messageDigest.digest(saltedPass.getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new IllegalStateException("UTF-8 not supported!"); - } - - if (getEncodeHashAsBase64()) { - return new String(Base64.encode(digest)); - } else { - return new String(Hex.encode(digest)); - } - } - - /** - * Get a MessageDigest instance for the given algorithm. - * Throws an IllegalArgumentException if algorithm is unknown - * - * @return MessageDigest instance - * @throws IllegalArgumentException if NoSuchAlgorithmException is thrown - */ - protected final MessageDigest getMessageDigest() throws IllegalArgumentException { - try { - return MessageDigest.getInstance(algorithm); - } catch (NoSuchAlgorithmException e) { - throw new IllegalArgumentException("No such algorithm [" + algorithm + "]"); - } - } - - /** - * Takes a previously encoded password and compares it with a rawpassword after mixing in the salt and - * encoding that value - * - * @param encPass previously encoded password - * @param rawPass plain text password - * @param salt salt to mix into password - * @return true or false - */ - public boolean isPasswordValid(String encPass, String rawPass, Object salt) { - String pass1 = "" + encPass; - String pass2 = encodePassword(rawPass, salt); - - return pass1.equals(pass2); - } - - public String getAlgorithm() { - return algorithm; - } -} +package org.springframework.security.authentication.encoding; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import org.springframework.security.core.codec.Base64; +import org.springframework.security.core.codec.Hex; + +/** + * Base for digest password encoders. + *

This class can be used stand-alone, or one of the subclasses can be used for compatiblity and convenience. + * When using this class directly you must specify a + * + * Message Digest Algorithm to use as a constructor arg

+ * + *

The encoded password hash is normally returned as Hex (32 char) version of the hash bytes. + * Setting the encodeHashAsBase64 property to true will cause the encoded pass to be returned + * as Base64 text, which will consume 24 characters. + * See {@link BaseDigestPasswordEncoder#setEncodeHashAsBase64(boolean)} + *

+ *

+ * This PasswordEncoder can be used directly as in the following example:
+ *

+ * <bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder">
+ *     <constructor-arg value="MD5"/>
+ * </bean>
+ * 
+ *

+ * + * @author Ray Krueger + * @since 1.0.1 + */ +public class MessageDigestPasswordEncoder extends BaseDigestPasswordEncoder { + + private final String algorithm; + + /** + * The digest algorithm to use + * Supports the named + * Message Digest Algorithms in the Java environment. + * + * @param algorithm + */ + public MessageDigestPasswordEncoder(String algorithm) { + this(algorithm, false); + } + + /** + * Convenience constructor for specifying the algorithm and whether or not to enable base64 encoding + * + * @param algorithm + * @param encodeHashAsBase64 + * @throws IllegalArgumentException if an unknown + */ + public MessageDigestPasswordEncoder(String algorithm, boolean encodeHashAsBase64) throws IllegalArgumentException { + this.algorithm = algorithm; + setEncodeHashAsBase64(encodeHashAsBase64); + //Validity Check + getMessageDigest(); + } + + /** + * Encodes the rawPass using a MessageDigest. + * If a salt is specified it will be merged with the password before encoding. + * + * @param rawPass The plain text password + * @param salt The salt to sprinkle + * @return Hex string of password digest (or base64 encoded string if encodeHashAsBase64 is enabled. + */ + public String encodePassword(String rawPass, Object salt) { + String saltedPass = mergePasswordAndSalt(rawPass, salt, false); + + MessageDigest messageDigest = getMessageDigest(); + + byte[] digest; + + try { + digest = messageDigest.digest(saltedPass.getBytes("UTF-8")); + } catch (UnsupportedEncodingException e) { + throw new IllegalStateException("UTF-8 not supported!"); + } + + if (getEncodeHashAsBase64()) { + return new String(Base64.encode(digest)); + } else { + return new String(Hex.encode(digest)); + } + } + + /** + * Get a MessageDigest instance for the given algorithm. + * Throws an IllegalArgumentException if algorithm is unknown + * + * @return MessageDigest instance + * @throws IllegalArgumentException if NoSuchAlgorithmException is thrown + */ + protected final MessageDigest getMessageDigest() throws IllegalArgumentException { + try { + return MessageDigest.getInstance(algorithm); + } catch (NoSuchAlgorithmException e) { + throw new IllegalArgumentException("No such algorithm [" + algorithm + "]"); + } + } + + /** + * Takes a previously encoded password and compares it with a rawpassword after mixing in the salt and + * encoding that value + * + * @param encPass previously encoded password + * @param rawPass plain text password + * @param salt salt to mix into password + * @return true or false + */ + public boolean isPasswordValid(String encPass, String rawPass, Object salt) { + String pass1 = "" + encPass; + String pass2 = encodePassword(rawPass, salt); + + return pass1.equals(pass2); + } + + public String getAlgorithm() { + return algorithm; + } +} diff --git a/core/src/main/java/org/springframework/security/authentication/encoding/PasswordEncoder.java b/core/src/main/java/org/springframework/security/authentication/encoding/PasswordEncoder.java index ac9d3ac9ab..54f1069d9b 100644 --- a/core/src/main/java/org/springframework/security/authentication/encoding/PasswordEncoder.java +++ b/core/src/main/java/org/springframework/security/authentication/encoding/PasswordEncoder.java @@ -24,7 +24,6 @@ import org.springframework.dao.DataAccessException; *

* * @author colin sampaleanu - * @version $Id$ */ public interface PasswordEncoder { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/encoding/PlaintextPasswordEncoder.java b/core/src/main/java/org/springframework/security/authentication/encoding/PlaintextPasswordEncoder.java index 707520e5aa..f414182b1c 100644 --- a/core/src/main/java/org/springframework/security/authentication/encoding/PlaintextPasswordEncoder.java +++ b/core/src/main/java/org/springframework/security/authentication/encoding/PlaintextPasswordEncoder.java @@ -22,7 +22,6 @@ package org.springframework.security.authentication.encoding; * * @author colin sampaleanu * @author Ben Alex - * @version $Id$ */ public class PlaintextPasswordEncoder extends BasePasswordEncoder { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/encoding/ShaPasswordEncoder.java b/core/src/main/java/org/springframework/security/authentication/encoding/ShaPasswordEncoder.java index 0f64a270ba..02658c9c83 100644 --- a/core/src/main/java/org/springframework/security/authentication/encoding/ShaPasswordEncoder.java +++ b/core/src/main/java/org/springframework/security/authentication/encoding/ShaPasswordEncoder.java @@ -33,7 +33,6 @@ package org.springframework.security.authentication.encoding; * @author Ray Krueger * @author colin sampaleanu * @author Ben Alex - * @version $Id$ */ public class ShaPasswordEncoder extends MessageDigestPasswordEncoder { diff --git a/core/src/main/java/org/springframework/security/authentication/event/AbstractAuthenticationEvent.java b/core/src/main/java/org/springframework/security/authentication/event/AbstractAuthenticationEvent.java index 5b8606db49..99bc1caea6 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/AbstractAuthenticationEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/event/AbstractAuthenticationEvent.java @@ -25,7 +25,6 @@ import org.springframework.context.ApplicationEvent; * be the Authentication object.

* * @author Ben Alex - * @version $Id$ */ public abstract class AbstractAuthenticationEvent extends ApplicationEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/event/AbstractAuthenticationFailureEvent.java b/core/src/main/java/org/springframework/security/authentication/event/AbstractAuthenticationFailureEvent.java index b389c13056..3b5025c7ff 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/AbstractAuthenticationFailureEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/event/AbstractAuthenticationFailureEvent.java @@ -25,7 +25,6 @@ import org.springframework.util.Assert; * Abstract application event which indicates authentication failure for some reason. * * @author Ben Alex - * @version $Id$ */ public abstract class AbstractAuthenticationFailureEvent extends AbstractAuthenticationEvent { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureBadCredentialsEvent.java b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureBadCredentialsEvent.java index 4301d251f0..10599f7f33 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureBadCredentialsEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureBadCredentialsEvent.java @@ -23,7 +23,6 @@ import org.springframework.security.core.AuthenticationException; * Application event which indicates authentication failure due to invalid credentials being presented. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationFailureBadCredentialsEvent extends AbstractAuthenticationFailureEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureCredentialsExpiredEvent.java b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureCredentialsExpiredEvent.java index f1031f75f5..9acf1ce142 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureCredentialsExpiredEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureCredentialsExpiredEvent.java @@ -23,7 +23,6 @@ import org.springframework.security.core.AuthenticationException; * Application event which indicates authentication failure due to the user's credentials having expired. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationFailureCredentialsExpiredEvent extends AbstractAuthenticationFailureEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureDisabledEvent.java b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureDisabledEvent.java index 9ed1a7b3a3..b789c9fda5 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureDisabledEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureDisabledEvent.java @@ -23,7 +23,6 @@ import org.springframework.security.core.AuthenticationException; * Application event which indicates authentication failure due to the user's account being disabled. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationFailureDisabledEvent extends AbstractAuthenticationFailureEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureExpiredEvent.java b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureExpiredEvent.java index 963d7ce018..f5f9719859 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureExpiredEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureExpiredEvent.java @@ -23,7 +23,6 @@ import org.springframework.security.core.AuthenticationException; * Application event which indicates authentication failure due to the user's account having expired. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationFailureExpiredEvent extends AbstractAuthenticationFailureEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureLockedEvent.java b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureLockedEvent.java index ae17e53a93..468153dc97 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureLockedEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureLockedEvent.java @@ -23,7 +23,6 @@ import org.springframework.security.core.AuthenticationException; * Application event which indicates authentication failure due to the user's account having been locked. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationFailureLockedEvent extends AbstractAuthenticationFailureEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureProviderNotFoundEvent.java b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureProviderNotFoundEvent.java index 1f3cd27020..8463fcbba0 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureProviderNotFoundEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureProviderNotFoundEvent.java @@ -24,7 +24,6 @@ import org.springframework.security.core.AuthenticationException; * AuthenticationProvider that can process the request. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationFailureProviderNotFoundEvent extends AbstractAuthenticationFailureEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureProxyUntrustedEvent.java b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureProxyUntrustedEvent.java index 84437ca104..587c14b59e 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureProxyUntrustedEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureProxyUntrustedEvent.java @@ -24,7 +24,6 @@ import org.springframework.security.core.AuthenticationException; * untrusted proxy. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationFailureProxyUntrustedEvent extends AbstractAuthenticationFailureEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureServiceExceptionEvent.java b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureServiceExceptionEvent.java index 460ef00502..9d42895734 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureServiceExceptionEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationFailureServiceExceptionEvent.java @@ -24,7 +24,6 @@ import org.springframework.security.core.AuthenticationException; * AuthenticationManager. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationFailureServiceExceptionEvent extends AbstractAuthenticationFailureEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationSuccessEvent.java b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationSuccessEvent.java index 1064fea060..58f0440097 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/AuthenticationSuccessEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/event/AuthenticationSuccessEvent.java @@ -22,7 +22,6 @@ import org.springframework.security.core.Authentication; * Application event which indicates successful authentication. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationSuccessEvent extends AbstractAuthenticationEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/event/InteractiveAuthenticationSuccessEvent.java b/core/src/main/java/org/springframework/security/authentication/event/InteractiveAuthenticationSuccessEvent.java index 0deee4da6f..db7f76bf59 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/InteractiveAuthenticationSuccessEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/event/InteractiveAuthenticationSuccessEvent.java @@ -25,7 +25,6 @@ import org.springframework.util.Assert; * source will be the Authentication object.

* * @author Ben Alex - * @version $Id$ */ public class InteractiveAuthenticationSuccessEvent extends AbstractAuthenticationEvent { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/event/LoggerListener.java b/core/src/main/java/org/springframework/security/authentication/event/LoggerListener.java index 477660d427..4bdd6e7f86 100644 --- a/core/src/main/java/org/springframework/security/authentication/event/LoggerListener.java +++ b/core/src/main/java/org/springframework/security/authentication/event/LoggerListener.java @@ -27,7 +27,6 @@ import org.springframework.util.ClassUtils; * All authentication events are logged at the warning level. * * @author Ben Alex - * @version $Id$ */ public class LoggerListener implements ApplicationListener { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/AuthorityGranter.java b/core/src/main/java/org/springframework/security/authentication/jaas/AuthorityGranter.java index eaa3383771..93108e6ffa 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/AuthorityGranter.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/AuthorityGranter.java @@ -28,7 +28,6 @@ import java.util.Set; * role for instance. * * @author Ray Krueger - * @version $Id$ */ public interface AuthorityGranter { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/DefaultLoginExceptionResolver.java b/core/src/main/java/org/springframework/security/authentication/jaas/DefaultLoginExceptionResolver.java index cdad0ba216..82245efe9c 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/DefaultLoginExceptionResolver.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/DefaultLoginExceptionResolver.java @@ -25,7 +25,6 @@ import javax.security.auth.login.LoginException; * This LoginExceptionResolver simply wraps the LoginException with an AuthenticationServiceException. * * @author Ray Krueger - * @version $Revision: 2142 $ */ public class DefaultLoginExceptionResolver implements LoginExceptionResolver { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationCallbackHandler.java b/core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationCallbackHandler.java index 99d2f23fd1..1a2e3ee83a 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationCallbackHandler.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationCallbackHandler.java @@ -38,7 +38,6 @@ import javax.security.auth.callback.UnsupportedCallbackException; *

* * @author Ray Krueger - * @version $Id$ * * @see JaasNameCallbackHandler * @see JaasPasswordCallbackHandler diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationProvider.java b/core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationProvider.java index 229404e442..9e2c87ab31 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/JaasAuthenticationProvider.java @@ -125,7 +125,6 @@ import org.springframework.util.Assert; *

* * @author Ray Krueger - * @version $Id$ */ public class JaasAuthenticationProvider implements AuthenticationProvider, ApplicationEventPublisherAware, InitializingBean, ApplicationListener { diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/JaasGrantedAuthority.java b/core/src/main/java/org/springframework/security/authentication/jaas/JaasGrantedAuthority.java index 4ee5b6ec38..b835250f0f 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/JaasGrantedAuthority.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/JaasGrantedAuthority.java @@ -25,7 +25,6 @@ import java.security.Principal; * Authority.
* * @author Ray Krueger - * @version $Id$ * * @see AuthorityGranter */ diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/JaasNameCallbackHandler.java b/core/src/main/java/org/springframework/security/authentication/jaas/JaasNameCallbackHandler.java index 3fbe141a4b..b57ce7cf00 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/JaasNameCallbackHandler.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/JaasNameCallbackHandler.java @@ -32,7 +32,6 @@ import javax.security.auth.callback.UnsupportedCallbackException; * handling the NameCallback.
* * @author Ray Krueger - * @version $Id$ * * @see Callback * @see * * @author Ray Krueger - * @version $Id$ * * @see Callback * @see diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/LoginExceptionResolver.java b/core/src/main/java/org/springframework/security/authentication/jaas/LoginExceptionResolver.java index e1fb1ab075..5a3addbf95 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/LoginExceptionResolver.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/LoginExceptionResolver.java @@ -29,7 +29,6 @@ import javax.security.auth.login.LoginException; * org.springframework.security.authentication.BadCredentialsException}. * * @author Ray Krueger - * @version $Revision: 2176 $ */ public interface LoginExceptionResolver { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/event/JaasAuthenticationEvent.java b/core/src/main/java/org/springframework/security/authentication/jaas/event/JaasAuthenticationEvent.java index c97a14e84d..7dbb1ec13a 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/event/JaasAuthenticationEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/event/JaasAuthenticationEvent.java @@ -25,7 +25,6 @@ import org.springframework.context.ApplicationEvent; * JaasAuthenticationProvider}. * * @author Ray Krueger - * @version $Id$ */ public abstract class JaasAuthenticationEvent extends ApplicationEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/event/JaasAuthenticationFailedEvent.java b/core/src/main/java/org/springframework/security/authentication/jaas/event/JaasAuthenticationFailedEvent.java index 85c9133dac..4e35b6b094 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/event/JaasAuthenticationFailedEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/event/JaasAuthenticationFailedEvent.java @@ -22,7 +22,6 @@ import org.springframework.security.core.Authentication; * Fired when LoginContext.login throws a LoginException, or if any other exception is thrown during that time. * * @author Ray Krueger - * @version $Id$ */ public class JaasAuthenticationFailedEvent extends JaasAuthenticationEvent { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/jaas/event/JaasAuthenticationSuccessEvent.java b/core/src/main/java/org/springframework/security/authentication/jaas/event/JaasAuthenticationSuccessEvent.java index 521f6ac066..627db4e5a6 100644 --- a/core/src/main/java/org/springframework/security/authentication/jaas/event/JaasAuthenticationSuccessEvent.java +++ b/core/src/main/java/org/springframework/security/authentication/jaas/event/JaasAuthenticationSuccessEvent.java @@ -24,7 +24,6 @@ import org.springframework.security.core.Authentication; * AuthorityGranters. * * @author Ray Krueger - * @version $Id$ */ public class JaasAuthenticationSuccessEvent extends JaasAuthenticationEvent { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationException.java b/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationException.java index 4102edb6f8..de73f62a28 100644 --- a/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationException.java +++ b/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationException.java @@ -25,7 +25,6 @@ import org.springframework.core.NestedRuntimeException; * the remoting protocol. * * @author Ben Alex - * @version $Id$ */ public class RemoteAuthenticationException extends NestedRuntimeException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManager.java b/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManager.java index 5597a94a83..0fe3211317 100644 --- a/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManager.java +++ b/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManager.java @@ -24,7 +24,6 @@ import org.springframework.security.core.GrantedAuthority; * Allows remote clients to attempt authentication. * * @author Ben Alex - * @version $Id$ */ public interface RemoteAuthenticationManager { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManagerImpl.java b/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManagerImpl.java index afbd7e52f3..528f1a81ce 100644 --- a/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManagerImpl.java +++ b/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManagerImpl.java @@ -32,7 +32,6 @@ import org.springframework.util.Assert; * AuthenticationManager to resolve an authentication request. * * @author Ben Alex - * @version $Id$ */ public class RemoteAuthenticationManagerImpl implements RemoteAuthenticationManager, InitializingBean { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationProvider.java b/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationProvider.java index 5d5a51d000..a3fd2c080a 100644 --- a/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/authentication/rcp/RemoteAuthenticationProvider.java @@ -42,7 +42,6 @@ import org.springframework.util.Assert; * be caught and displayed to the user, enabling them to retry with alternative credentials etc.

* * @author Ben Alex - * @version $Id$ */ public class RemoteAuthenticationProvider implements AuthenticationProvider, InitializingBean { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/core/Authentication.java b/core/src/main/java/org/springframework/security/core/Authentication.java index 23caff103f..0f5002d79c 100644 --- a/core/src/main/java/org/springframework/security/core/Authentication.java +++ b/core/src/main/java/org/springframework/security/core/Authentication.java @@ -43,7 +43,6 @@ import org.springframework.security.core.context.SecurityContextHolder; * for you. * * @author Ben Alex - * @version $Id$ */ public interface Authentication extends Principal, Serializable { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/AuthenticationException.java b/core/src/main/java/org/springframework/security/core/AuthenticationException.java index 5b600616d3..5f1490050a 100644 --- a/core/src/main/java/org/springframework/security/core/AuthenticationException.java +++ b/core/src/main/java/org/springframework/security/core/AuthenticationException.java @@ -20,7 +20,6 @@ package org.springframework.security.core; * reason. * * @author Ben Alex - * @version $Id$ */ public abstract class AuthenticationException extends RuntimeException { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/core/GrantedAuthority.java b/core/src/main/java/org/springframework/security/core/GrantedAuthority.java index 340cc36e60..cfdd92dd7a 100644 --- a/core/src/main/java/org/springframework/security/core/GrantedAuthority.java +++ b/core/src/main/java/org/springframework/security/core/GrantedAuthority.java @@ -28,7 +28,6 @@ import org.springframework.security.access.AccessDecisionManager; * AccessDecisionManager}. * * @author Ben Alex - * @version $Id$ */ public interface GrantedAuthority extends Serializable { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/SpringSecurityMessageSource.java b/core/src/main/java/org/springframework/security/core/SpringSecurityMessageSource.java index a721d7d44b..fcff0ff24d 100644 --- a/core/src/main/java/org/springframework/security/core/SpringSecurityMessageSource.java +++ b/core/src/main/java/org/springframework/security/core/SpringSecurityMessageSource.java @@ -27,7 +27,6 @@ import org.springframework.context.support.ResourceBundleMessageSource; * specified an alternative message source.

* * @author Ben Alex - * @version $Id$ */ public class SpringSecurityMessageSource extends ResourceBundleMessageSource { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/authority/AuthorityUtils.java b/core/src/main/java/org/springframework/security/core/authority/AuthorityUtils.java index 6d6daf6e07..50de8f772f 100644 --- a/core/src/main/java/org/springframework/security/core/authority/AuthorityUtils.java +++ b/core/src/main/java/org/springframework/security/core/authority/AuthorityUtils.java @@ -16,7 +16,6 @@ import org.springframework.util.StringUtils; * Mainly intended for internal use. * * @author Luke Taylor - * @version $Id$ */ public abstract class AuthorityUtils { public static final List NO_AUTHORITIES = Collections.emptyList(); diff --git a/core/src/main/java/org/springframework/security/core/authority/GrantedAuthoritiesContainer.java b/core/src/main/java/org/springframework/security/core/authority/GrantedAuthoritiesContainer.java index b768f59665..514af0da02 100644 --- a/core/src/main/java/org/springframework/security/core/authority/GrantedAuthoritiesContainer.java +++ b/core/src/main/java/org/springframework/security/core/authority/GrantedAuthoritiesContainer.java @@ -9,7 +9,7 @@ import org.springframework.security.core.GrantedAuthority; * Indicates that a object stores GrantedAuthority objects. *

* Typically used in a pre-authenticated scenario when an AuthenticationDetails instance may also be - * used to obtain user authorities. + * used to obtain user authorities. * * @author Ruud Senden * @author Luke Taylor diff --git a/core/src/main/java/org/springframework/security/core/authority/MutableGrantedAuthoritiesContainer.java b/core/src/main/java/org/springframework/security/core/authority/MutableGrantedAuthoritiesContainer.java index 0fa77ce214..30d9cd1dcb 100644 --- a/core/src/main/java/org/springframework/security/core/authority/MutableGrantedAuthoritiesContainer.java +++ b/core/src/main/java/org/springframework/security/core/authority/MutableGrantedAuthoritiesContainer.java @@ -8,8 +8,8 @@ import org.springframework.security.core.GrantedAuthority; * Indicates that a object can be used to store and retrieve GrantedAuthority objects. *

* Typically used in a pre-authenticated scenario when an AuthenticationDetails instance may also be - * used to obtain user authorities. - * + * used to obtain user authorities. + * * @author Ruud Senden * @author Luke Taylor * @since 2.0 diff --git a/core/src/main/java/org/springframework/security/core/authority/mapping/Attributes2GrantedAuthoritiesMapper.java b/core/src/main/java/org/springframework/security/core/authority/mapping/Attributes2GrantedAuthoritiesMapper.java index 28f6a6241a..434106b8e4 100755 --- a/core/src/main/java/org/springframework/security/core/authority/mapping/Attributes2GrantedAuthoritiesMapper.java +++ b/core/src/main/java/org/springframework/security/core/authority/mapping/Attributes2GrantedAuthoritiesMapper.java @@ -1,27 +1,27 @@ -package org.springframework.security.core.authority.mapping; - -import java.util.Collection; -import java.util.List; - -import org.springframework.security.core.GrantedAuthority; - -/** - * Interface to be implemented by classes that can map a list of security attributes (such as roles or - * group names) to a list of Spring Security GrantedAuthorities. - * - * @author Ruud Senden - * @since 2.0 - */ -public interface Attributes2GrantedAuthoritiesMapper { - /** - * Implementations of this method should map the given list of attributes to a - * list of Spring Security GrantedAuthorities. There are no restrictions for the - * mapping process; a single attribute can be mapped to multiple Spring Security - * GrantedAuthorities, all attributes can be mapped to a single Spring Security - * GrantedAuthority, some attributes may not be mapped, etc. - * - * @param attribute the attributes to be mapped - * @return the list of mapped GrantedAuthorities - */ - public List getGrantedAuthorities(Collection attributes); -} +package org.springframework.security.core.authority.mapping; + +import java.util.Collection; +import java.util.List; + +import org.springframework.security.core.GrantedAuthority; + +/** + * Interface to be implemented by classes that can map a list of security attributes (such as roles or + * group names) to a list of Spring Security GrantedAuthorities. + * + * @author Ruud Senden + * @since 2.0 + */ +public interface Attributes2GrantedAuthoritiesMapper { + /** + * Implementations of this method should map the given list of attributes to a + * list of Spring Security GrantedAuthorities. There are no restrictions for the + * mapping process; a single attribute can be mapped to multiple Spring Security + * GrantedAuthorities, all attributes can be mapped to a single Spring Security + * GrantedAuthority, some attributes may not be mapped, etc. + * + * @param attribute the attributes to be mapped + * @return the list of mapped GrantedAuthorities + */ + public List getGrantedAuthorities(Collection attributes); +} diff --git a/core/src/main/java/org/springframework/security/core/authority/mapping/MapBasedAttributes2GrantedAuthoritiesMapper.java b/core/src/main/java/org/springframework/security/core/authority/mapping/MapBasedAttributes2GrantedAuthoritiesMapper.java index 3cc30c0441..ff3d2f5166 100755 --- a/core/src/main/java/org/springframework/security/core/authority/mapping/MapBasedAttributes2GrantedAuthoritiesMapper.java +++ b/core/src/main/java/org/springframework/security/core/authority/mapping/MapBasedAttributes2GrantedAuthoritiesMapper.java @@ -1,165 +1,165 @@ -package org.springframework.security.core.authority.mapping; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.StringTokenizer; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthorityImpl; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; - -/** - * This class implements the Attributes2GrantedAuthoritiesMapper and - * MappableAttributesRetriever interfaces based on the supplied Map. - * It supports both one-to-one and one-to-many mappings. The granted - * authorities to map to can be supplied either as a String or as a - * GrantedAuthority object. - * - * @author Ruud Senden - */ -public class MapBasedAttributes2GrantedAuthoritiesMapper implements Attributes2GrantedAuthoritiesMapper, MappableAttributesRetriever, InitializingBean { - private Map> attributes2grantedAuthoritiesMap = null; - private String stringSeparator = ","; - private Set mappableAttributes = null; - - - public void afterPropertiesSet() throws Exception { - Assert.notNull(attributes2grantedAuthoritiesMap, "attributes2grantedAuthoritiesMap must be set"); - } - - /** - * Map the given array of attributes to Spring Security GrantedAuthorities. - */ - public List getGrantedAuthorities(Collection attributes) { - ArrayList gaList = new ArrayList(); - for (String attribute : attributes) { - Collection c = attributes2grantedAuthoritiesMap.get(attribute); - if ( c != null ) { gaList.addAll(c); } - } - gaList.trimToSize(); - - return gaList; - } - - /** - * @return Returns the attributes2grantedAuthoritiesMap. - */ - public Map> getAttributes2grantedAuthoritiesMap() { - return attributes2grantedAuthoritiesMap; - } - /** - * @param attributes2grantedAuthoritiesMap The attributes2grantedAuthoritiesMap to set. - */ - public void setAttributes2grantedAuthoritiesMap(final Map attributes2grantedAuthoritiesMap) { - Assert.notEmpty(attributes2grantedAuthoritiesMap,"A non-empty attributes2grantedAuthoritiesMap must be supplied"); - this.attributes2grantedAuthoritiesMap = preProcessMap(attributes2grantedAuthoritiesMap); - - mappableAttributes = Collections.unmodifiableSet(this.attributes2grantedAuthoritiesMap.keySet()); - } - - /** - * Preprocess the given map to convert all the values to GrantedAuthority collections - * - * @param orgMap The map to process - * @return the processed Map - */ - private Map> preProcessMap(Map orgMap) { - Map> result = - new HashMap>(orgMap.size()); - - for(Map.Entry entry : orgMap.entrySet()) { - Assert.isInstanceOf(String.class, entry.getKey(), - "attributes2grantedAuthoritiesMap contains non-String objects as keys"); - result.put((String)entry.getKey(),getGrantedAuthorityCollection(entry.getValue())); - } - return result; - } - - /** - * Convert the given value to a collection of Granted Authorities - * - * @param value - * The value to convert to a GrantedAuthority Collection - * @return Collection containing the GrantedAuthority Collection - */ - private Collection getGrantedAuthorityCollection(Object value) { - Collection result = new ArrayList(); - addGrantedAuthorityCollection(result,value); - return result; - } - - /** - * Convert the given value to a collection of Granted Authorities, - * adding the result to the given result collection. - * - * @param value - * The value to convert to a GrantedAuthority Collection - * @return Collection containing the GrantedAuthority Collection - */ - private void addGrantedAuthorityCollection(Collection result, Object value) { - if ( value == null ) { - return; - } - if ( value instanceof Collection ) { - addGrantedAuthorityCollection(result,(Collection)value); - } else if ( value instanceof Object[] ) { - addGrantedAuthorityCollection(result,(Object[])value); - } else if ( value instanceof String ) { - addGrantedAuthorityCollection(result,(String)value); - } else if ( value instanceof GrantedAuthority ) { - result.add((GrantedAuthority) value); - } else { - throw new IllegalArgumentException("Invalid object type: "+value.getClass().getName()); - } - } - - private void addGrantedAuthorityCollection(Collection result, Collection value) { - for(Object elt : value) { - addGrantedAuthorityCollection(result, elt); - } - } - - private void addGrantedAuthorityCollection(Collection result, Object[] value) { - for ( int i = 0 ; i < value.length ; i++ ) { - addGrantedAuthorityCollection(result,value[i]); - } - } - - private void addGrantedAuthorityCollection(Collection result, String value) { - StringTokenizer st = new StringTokenizer(value,stringSeparator,false); - while ( st.hasMoreTokens() ) { - String nextToken = st.nextToken(); - if ( StringUtils.hasText(nextToken) ) { - result.add(new GrantedAuthorityImpl(nextToken)); - } - } - } - - /** - * - * @see org.springframework.security.core.authority.mapping.MappableAttributesRetriever#getMappableAttributes() - */ - public Set getMappableAttributes() { - return mappableAttributes; - } - /** - * @return Returns the stringSeparator. - */ - public String getStringSeparator() { - return stringSeparator; - } - /** - * @param stringSeparator The stringSeparator to set. - */ - public void setStringSeparator(String stringSeparator) { - this.stringSeparator = stringSeparator; - } - -} +package org.springframework.security.core.authority.mapping; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.GrantedAuthorityImpl; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; + +/** + * This class implements the Attributes2GrantedAuthoritiesMapper and + * MappableAttributesRetriever interfaces based on the supplied Map. + * It supports both one-to-one and one-to-many mappings. The granted + * authorities to map to can be supplied either as a String or as a + * GrantedAuthority object. + * + * @author Ruud Senden + */ +public class MapBasedAttributes2GrantedAuthoritiesMapper implements Attributes2GrantedAuthoritiesMapper, MappableAttributesRetriever, InitializingBean { + private Map> attributes2grantedAuthoritiesMap = null; + private String stringSeparator = ","; + private Set mappableAttributes = null; + + + public void afterPropertiesSet() throws Exception { + Assert.notNull(attributes2grantedAuthoritiesMap, "attributes2grantedAuthoritiesMap must be set"); + } + + /** + * Map the given array of attributes to Spring Security GrantedAuthorities. + */ + public List getGrantedAuthorities(Collection attributes) { + ArrayList gaList = new ArrayList(); + for (String attribute : attributes) { + Collection c = attributes2grantedAuthoritiesMap.get(attribute); + if ( c != null ) { gaList.addAll(c); } + } + gaList.trimToSize(); + + return gaList; + } + + /** + * @return Returns the attributes2grantedAuthoritiesMap. + */ + public Map> getAttributes2grantedAuthoritiesMap() { + return attributes2grantedAuthoritiesMap; + } + /** + * @param attributes2grantedAuthoritiesMap The attributes2grantedAuthoritiesMap to set. + */ + public void setAttributes2grantedAuthoritiesMap(final Map attributes2grantedAuthoritiesMap) { + Assert.notEmpty(attributes2grantedAuthoritiesMap,"A non-empty attributes2grantedAuthoritiesMap must be supplied"); + this.attributes2grantedAuthoritiesMap = preProcessMap(attributes2grantedAuthoritiesMap); + + mappableAttributes = Collections.unmodifiableSet(this.attributes2grantedAuthoritiesMap.keySet()); + } + + /** + * Preprocess the given map to convert all the values to GrantedAuthority collections + * + * @param orgMap The map to process + * @return the processed Map + */ + private Map> preProcessMap(Map orgMap) { + Map> result = + new HashMap>(orgMap.size()); + + for(Map.Entry entry : orgMap.entrySet()) { + Assert.isInstanceOf(String.class, entry.getKey(), + "attributes2grantedAuthoritiesMap contains non-String objects as keys"); + result.put((String)entry.getKey(),getGrantedAuthorityCollection(entry.getValue())); + } + return result; + } + + /** + * Convert the given value to a collection of Granted Authorities + * + * @param value + * The value to convert to a GrantedAuthority Collection + * @return Collection containing the GrantedAuthority Collection + */ + private Collection getGrantedAuthorityCollection(Object value) { + Collection result = new ArrayList(); + addGrantedAuthorityCollection(result,value); + return result; + } + + /** + * Convert the given value to a collection of Granted Authorities, + * adding the result to the given result collection. + * + * @param value + * The value to convert to a GrantedAuthority Collection + * @return Collection containing the GrantedAuthority Collection + */ + private void addGrantedAuthorityCollection(Collection result, Object value) { + if ( value == null ) { + return; + } + if ( value instanceof Collection ) { + addGrantedAuthorityCollection(result,(Collection)value); + } else if ( value instanceof Object[] ) { + addGrantedAuthorityCollection(result,(Object[])value); + } else if ( value instanceof String ) { + addGrantedAuthorityCollection(result,(String)value); + } else if ( value instanceof GrantedAuthority ) { + result.add((GrantedAuthority) value); + } else { + throw new IllegalArgumentException("Invalid object type: "+value.getClass().getName()); + } + } + + private void addGrantedAuthorityCollection(Collection result, Collection value) { + for(Object elt : value) { + addGrantedAuthorityCollection(result, elt); + } + } + + private void addGrantedAuthorityCollection(Collection result, Object[] value) { + for ( int i = 0 ; i < value.length ; i++ ) { + addGrantedAuthorityCollection(result,value[i]); + } + } + + private void addGrantedAuthorityCollection(Collection result, String value) { + StringTokenizer st = new StringTokenizer(value,stringSeparator,false); + while ( st.hasMoreTokens() ) { + String nextToken = st.nextToken(); + if ( StringUtils.hasText(nextToken) ) { + result.add(new GrantedAuthorityImpl(nextToken)); + } + } + } + + /** + * + * @see org.springframework.security.core.authority.mapping.MappableAttributesRetriever#getMappableAttributes() + */ + public Set getMappableAttributes() { + return mappableAttributes; + } + /** + * @return Returns the stringSeparator. + */ + public String getStringSeparator() { + return stringSeparator; + } + /** + * @param stringSeparator The stringSeparator to set. + */ + public void setStringSeparator(String stringSeparator) { + this.stringSeparator = stringSeparator; + } + +} diff --git a/core/src/main/java/org/springframework/security/core/authority/mapping/MappableAttributesRetriever.java b/core/src/main/java/org/springframework/security/core/authority/mapping/MappableAttributesRetriever.java index 7054a7ba1b..5384403bd4 100755 --- a/core/src/main/java/org/springframework/security/core/authority/mapping/MappableAttributesRetriever.java +++ b/core/src/main/java/org/springframework/security/core/authority/mapping/MappableAttributesRetriever.java @@ -1,21 +1,21 @@ -package org.springframework.security.core.authority.mapping; - -import java.util.Set; - -/** - * Interface to be implemented by classes that can retrieve a list of mappable - * security attribute strings (for example the list of all available J2EE roles in a web or EJB - * application). - * - * @author Ruud Senden - * @since 2.0 - */ -public interface MappableAttributesRetriever { - /** - * Implementations of this method should return a set of all string attributes which - * can be mapped to GrantedAuthoritys. - * - * @return set of all mappable roles - */ - Set getMappableAttributes(); -} +package org.springframework.security.core.authority.mapping; + +import java.util.Set; + +/** + * Interface to be implemented by classes that can retrieve a list of mappable + * security attribute strings (for example the list of all available J2EE roles in a web or EJB + * application). + * + * @author Ruud Senden + * @since 2.0 + */ +public interface MappableAttributesRetriever { + /** + * Implementations of this method should return a set of all string attributes which + * can be mapped to GrantedAuthoritys. + * + * @return set of all mappable roles + */ + Set getMappableAttributes(); +} diff --git a/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleAttributes2GrantedAuthoritiesMapper.java b/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleAttributes2GrantedAuthoritiesMapper.java index 644fed7363..723eb2e442 100755 --- a/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleAttributes2GrantedAuthoritiesMapper.java +++ b/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleAttributes2GrantedAuthoritiesMapper.java @@ -1,108 +1,108 @@ -package org.springframework.security.core.authority.mapping; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthorityImpl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Locale; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.util.Assert; - -/** - *

- * This class implements the Attributes2GrantedAuthoritiesMapper interface by doing a - * one-to-one mapping from roles to Spring Security GrantedAuthorities. Optionally a - * prefix can be added, and the attribute name can be converted to upper or lower - * case. - *

- * By default, the attribute is prefixed with "ROLE_" unless it already starts with - * "ROLE_", and no case conversion is done. - * - * @author Ruud Senden - * @since 2.0 - */ -public class SimpleAttributes2GrantedAuthoritiesMapper implements Attributes2GrantedAuthoritiesMapper, InitializingBean { - private String attributePrefix = "ROLE_"; - - private boolean convertAttributeToUpperCase = false; - - private boolean convertAttributeToLowerCase = false; - - private boolean addPrefixIfAlreadyExisting = false; - - /** - * Check whether all properties have been set to correct values. - */ - public void afterPropertiesSet() throws Exception { - Assert.isTrue(!(isConvertAttributeToUpperCase() && isConvertAttributeToLowerCase()), - "Either convertAttributeToUpperCase or convertAttributeToLowerCase can be set to true, but not both"); - } - - /** - * Map the given list of string attributes one-to-one to Spring Security GrantedAuthorities. - */ - public List getGrantedAuthorities(Collection attributes) { - List result = new ArrayList(attributes.size()); - for (String attribute : attributes) { - result.add(getGrantedAuthority(attribute)); - } - return result; - } - - /** - * Map the given role one-on-one to a Spring Security GrantedAuthority, optionally - * doing case conversion and/or adding a prefix. - * - * @param attribute - * The attribute for which to get a GrantedAuthority - * @return GrantedAuthority representing the given role. - */ - private GrantedAuthority getGrantedAuthority(String attribute) { - if (isConvertAttributeToLowerCase()) { - attribute = attribute.toLowerCase(Locale.getDefault()); - } else if (isConvertAttributeToUpperCase()) { - attribute = attribute.toUpperCase(Locale.getDefault()); - } - if (isAddPrefixIfAlreadyExisting() || !attribute.startsWith(getAttributePrefix())) { - return new GrantedAuthorityImpl(getAttributePrefix() + attribute); - } else { - return new GrantedAuthorityImpl(attribute); - } - } - - private boolean isConvertAttributeToLowerCase() { - return convertAttributeToLowerCase; - } - - public void setConvertAttributeToLowerCase(boolean b) { - convertAttributeToLowerCase = b; - } - - private boolean isConvertAttributeToUpperCase() { - return convertAttributeToUpperCase; - } - - public void setConvertAttributeToUpperCase(boolean b) { - convertAttributeToUpperCase = b; - } - - private String getAttributePrefix() { - return attributePrefix == null ? "" : attributePrefix; - } - - public void setAttributePrefix(String string) { - attributePrefix = string; - } - - private boolean isAddPrefixIfAlreadyExisting() { - return addPrefixIfAlreadyExisting; - } - - public void setAddPrefixIfAlreadyExisting(boolean b) { - addPrefixIfAlreadyExisting = b; - } - -} +package org.springframework.security.core.authority.mapping; + +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.GrantedAuthorityImpl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Locale; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.util.Assert; + +/** + *

+ * This class implements the Attributes2GrantedAuthoritiesMapper interface by doing a + * one-to-one mapping from roles to Spring Security GrantedAuthorities. Optionally a + * prefix can be added, and the attribute name can be converted to upper or lower + * case. + *

+ * By default, the attribute is prefixed with "ROLE_" unless it already starts with + * "ROLE_", and no case conversion is done. + * + * @author Ruud Senden + * @since 2.0 + */ +public class SimpleAttributes2GrantedAuthoritiesMapper implements Attributes2GrantedAuthoritiesMapper, InitializingBean { + private String attributePrefix = "ROLE_"; + + private boolean convertAttributeToUpperCase = false; + + private boolean convertAttributeToLowerCase = false; + + private boolean addPrefixIfAlreadyExisting = false; + + /** + * Check whether all properties have been set to correct values. + */ + public void afterPropertiesSet() throws Exception { + Assert.isTrue(!(isConvertAttributeToUpperCase() && isConvertAttributeToLowerCase()), + "Either convertAttributeToUpperCase or convertAttributeToLowerCase can be set to true, but not both"); + } + + /** + * Map the given list of string attributes one-to-one to Spring Security GrantedAuthorities. + */ + public List getGrantedAuthorities(Collection attributes) { + List result = new ArrayList(attributes.size()); + for (String attribute : attributes) { + result.add(getGrantedAuthority(attribute)); + } + return result; + } + + /** + * Map the given role one-on-one to a Spring Security GrantedAuthority, optionally + * doing case conversion and/or adding a prefix. + * + * @param attribute + * The attribute for which to get a GrantedAuthority + * @return GrantedAuthority representing the given role. + */ + private GrantedAuthority getGrantedAuthority(String attribute) { + if (isConvertAttributeToLowerCase()) { + attribute = attribute.toLowerCase(Locale.getDefault()); + } else if (isConvertAttributeToUpperCase()) { + attribute = attribute.toUpperCase(Locale.getDefault()); + } + if (isAddPrefixIfAlreadyExisting() || !attribute.startsWith(getAttributePrefix())) { + return new GrantedAuthorityImpl(getAttributePrefix() + attribute); + } else { + return new GrantedAuthorityImpl(attribute); + } + } + + private boolean isConvertAttributeToLowerCase() { + return convertAttributeToLowerCase; + } + + public void setConvertAttributeToLowerCase(boolean b) { + convertAttributeToLowerCase = b; + } + + private boolean isConvertAttributeToUpperCase() { + return convertAttributeToUpperCase; + } + + public void setConvertAttributeToUpperCase(boolean b) { + convertAttributeToUpperCase = b; + } + + private String getAttributePrefix() { + return attributePrefix == null ? "" : attributePrefix; + } + + public void setAttributePrefix(String string) { + attributePrefix = string; + } + + private boolean isAddPrefixIfAlreadyExisting() { + return addPrefixIfAlreadyExisting; + } + + public void setAddPrefixIfAlreadyExisting(boolean b) { + addPrefixIfAlreadyExisting = b; + } + +} diff --git a/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleMappableAttributesRetriever.java b/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleMappableAttributesRetriever.java index 4d49c54038..b49c85c011 100755 --- a/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleMappableAttributesRetriever.java +++ b/core/src/main/java/org/springframework/security/core/authority/mapping/SimpleMappableAttributesRetriever.java @@ -1,34 +1,34 @@ -package org.springframework.security.core.authority.mapping; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -/** - * This class implements the MappableAttributesRetriever interface by just returning - * a list of mappable attributes as previously set using the corresponding setter - * method. - * - * @author Ruud Senden - * @since 2.0 - */ -public class SimpleMappableAttributesRetriever implements MappableAttributesRetriever { - private Set mappableAttributes = null; - - /* - * (non-Javadoc) - * - * @see org.springframework.security.core.authority.mapping.MappableAttributesRetriever#getMappableAttributes() - */ - public Set getMappableAttributes() { - return mappableAttributes; - } - - @SuppressWarnings("unchecked") - public void setMappableAttributes(Set aMappableRoles) { - mappableAttributes = new HashSet(); - mappableAttributes.addAll(aMappableRoles); - mappableAttributes = Collections.unmodifiableSet(mappableAttributes); - } - -} +package org.springframework.security.core.authority.mapping; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * This class implements the MappableAttributesRetriever interface by just returning + * a list of mappable attributes as previously set using the corresponding setter + * method. + * + * @author Ruud Senden + * @since 2.0 + */ +public class SimpleMappableAttributesRetriever implements MappableAttributesRetriever { + private Set mappableAttributes = null; + + /* + * (non-Javadoc) + * + * @see org.springframework.security.core.authority.mapping.MappableAttributesRetriever#getMappableAttributes() + */ + public Set getMappableAttributes() { + return mappableAttributes; + } + + @SuppressWarnings("unchecked") + public void setMappableAttributes(Set aMappableRoles) { + mappableAttributes = new HashSet(); + mappableAttributes.addAll(aMappableRoles); + mappableAttributes = Collections.unmodifiableSet(mappableAttributes); + } + +} diff --git a/core/src/main/java/org/springframework/security/core/codec/Base64.java b/core/src/main/java/org/springframework/security/core/codec/Base64.java index 839ceb3656..b4f11fa176 100644 --- a/core/src/main/java/org/springframework/security/core/codec/Base64.java +++ b/core/src/main/java/org/springframework/security/core/codec/Base64.java @@ -8,7 +8,6 @@ package org.springframework.security.core.codec; * For internal use only. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public final class Base64 { diff --git a/core/src/main/java/org/springframework/security/core/codec/Hex.java b/core/src/main/java/org/springframework/security/core/codec/Hex.java index 4dd7548263..d1d3105eec 100644 --- a/core/src/main/java/org/springframework/security/core/codec/Hex.java +++ b/core/src/main/java/org/springframework/security/core/codec/Hex.java @@ -7,7 +7,6 @@ package org.springframework.security.core.codec; * For internal use only. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public final class Hex { diff --git a/core/src/main/java/org/springframework/security/core/context/GlobalSecurityContextHolderStrategy.java b/core/src/main/java/org/springframework/security/core/context/GlobalSecurityContextHolderStrategy.java index 4f3675c2bb..8d83c34ad5 100644 --- a/core/src/main/java/org/springframework/security/core/context/GlobalSecurityContextHolderStrategy.java +++ b/core/src/main/java/org/springframework/security/core/context/GlobalSecurityContextHolderStrategy.java @@ -1,57 +1,56 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.core.context; - -import org.springframework.util.Assert; - - -/** - * A static field-based implementation of {@link SecurityContextHolderStrategy}. - *

- * This means that all instances in the JVM share the - * same SecurityContext. This is generally useful with rich clients, such as Swing. - * - * @author Ben Alex - * @version $Id$ - */ -final class GlobalSecurityContextHolderStrategy implements SecurityContextHolderStrategy { - //~ Static fields/initializers ===================================================================================== - - private static SecurityContext contextHolder; - - //~ Methods ======================================================================================================== - - public void clearContext() { - contextHolder = null; - } - - public SecurityContext getContext() { - if (contextHolder == null) { - contextHolder = new SecurityContextImpl(); - } - - return contextHolder; - } - - public void setContext(SecurityContext context) { - Assert.notNull(context, "Only non-null SecurityContext instances are permitted"); - contextHolder = context; - } - - public SecurityContext createEmptyContext() { - return new SecurityContextImpl(); - } -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.core.context; + +import org.springframework.util.Assert; + + +/** + * A static field-based implementation of {@link SecurityContextHolderStrategy}. + *

+ * This means that all instances in the JVM share the + * same SecurityContext. This is generally useful with rich clients, such as Swing. + * + * @author Ben Alex + */ +final class GlobalSecurityContextHolderStrategy implements SecurityContextHolderStrategy { + //~ Static fields/initializers ===================================================================================== + + private static SecurityContext contextHolder; + + //~ Methods ======================================================================================================== + + public void clearContext() { + contextHolder = null; + } + + public SecurityContext getContext() { + if (contextHolder == null) { + contextHolder = new SecurityContextImpl(); + } + + return contextHolder; + } + + public void setContext(SecurityContext context) { + Assert.notNull(context, "Only non-null SecurityContext instances are permitted"); + contextHolder = context; + } + + public SecurityContext createEmptyContext() { + return new SecurityContextImpl(); + } +} diff --git a/core/src/main/java/org/springframework/security/core/context/InheritableThreadLocalSecurityContextHolderStrategy.java b/core/src/main/java/org/springframework/security/core/context/InheritableThreadLocalSecurityContextHolderStrategy.java index 7d79bdc023..888805c696 100644 --- a/core/src/main/java/org/springframework/security/core/context/InheritableThreadLocalSecurityContextHolderStrategy.java +++ b/core/src/main/java/org/springframework/security/core/context/InheritableThreadLocalSecurityContextHolderStrategy.java @@ -1,61 +1,60 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.core.context; - -import org.springframework.util.Assert; - - -/** - * An InheritableThreadLocal-based implementation of {@link - * org.springframework.security.core.context.SecurityContextHolderStrategy}. - * - * @author Ben Alex - * @version $Id$ - * - * @see java.lang.ThreadLocal - * @see org.springframework.security.core.context.web.SecurityContextPersistenceFilter - */ -final class InheritableThreadLocalSecurityContextHolderStrategy implements SecurityContextHolderStrategy { - //~ Static fields/initializers ===================================================================================== - - private static final ThreadLocal contextHolder = new InheritableThreadLocal(); - - //~ Methods ======================================================================================================== - - public void clearContext() { - contextHolder.set(null); - } - - public SecurityContext getContext() { - SecurityContext ctx = contextHolder.get(); - - if (ctx == null) { - ctx = createEmptyContext(); - contextHolder.set(ctx); - } - - return ctx; - } - - public void setContext(SecurityContext context) { - Assert.notNull(context, "Only non-null SecurityContext instances are permitted"); - contextHolder.set(context); - } - - public SecurityContext createEmptyContext() { - return new SecurityContextImpl(); - } -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.core.context; + +import org.springframework.util.Assert; + + +/** + * An InheritableThreadLocal-based implementation of {@link + * org.springframework.security.core.context.SecurityContextHolderStrategy}. + * + * @author Ben Alex + * + * @see java.lang.ThreadLocal + * @see org.springframework.security.core.context.web.SecurityContextPersistenceFilter + */ +final class InheritableThreadLocalSecurityContextHolderStrategy implements SecurityContextHolderStrategy { + //~ Static fields/initializers ===================================================================================== + + private static final ThreadLocal contextHolder = new InheritableThreadLocal(); + + //~ Methods ======================================================================================================== + + public void clearContext() { + contextHolder.set(null); + } + + public SecurityContext getContext() { + SecurityContext ctx = contextHolder.get(); + + if (ctx == null) { + ctx = createEmptyContext(); + contextHolder.set(ctx); + } + + return ctx; + } + + public void setContext(SecurityContext context) { + Assert.notNull(context, "Only non-null SecurityContext instances are permitted"); + contextHolder.set(context); + } + + public SecurityContext createEmptyContext() { + return new SecurityContextImpl(); + } +} diff --git a/core/src/main/java/org/springframework/security/core/context/SecurityContext.java b/core/src/main/java/org/springframework/security/core/context/SecurityContext.java index ac5546bacb..26df7890ea 100644 --- a/core/src/main/java/org/springframework/security/core/context/SecurityContext.java +++ b/core/src/main/java/org/springframework/security/core/context/SecurityContext.java @@ -29,7 +29,6 @@ import java.io.Serializable; *

* * @author Ben Alex - * @version $Id$ */ public interface SecurityContext extends Serializable { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/context/SecurityContextHolder.java b/core/src/main/java/org/springframework/security/core/context/SecurityContextHolder.java index c6122d527d..b00df408cb 100644 --- a/core/src/main/java/org/springframework/security/core/context/SecurityContextHolder.java +++ b/core/src/main/java/org/springframework/security/core/context/SecurityContextHolder.java @@ -41,7 +41,6 @@ import java.lang.reflect.Constructor; * #MODE_GLOBAL} is definitely inappropriate for server use). * * @author Ben Alex - * @version $Id$ * */ public class SecurityContextHolder { diff --git a/core/src/main/java/org/springframework/security/core/context/SecurityContextHolderStrategy.java b/core/src/main/java/org/springframework/security/core/context/SecurityContextHolderStrategy.java index 4a127d6a11..291a825947 100644 --- a/core/src/main/java/org/springframework/security/core/context/SecurityContextHolderStrategy.java +++ b/core/src/main/java/org/springframework/security/core/context/SecurityContextHolderStrategy.java @@ -1,57 +1,56 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.core.context; - -/** - * A strategy for storing security context information against a thread. - * - *

- * The preferred strategy is loaded by {@link SecurityContextHolder}. - * - * @author Ben Alex - * @version $Id$ - */ -public interface SecurityContextHolderStrategy { - //~ Methods ======================================================================================================== - - /** - * Clears the current context. - */ - void clearContext(); - - /** - * Obtains the current context. - * - * @return a context (never null - create a default implementation if necessary) - */ - SecurityContext getContext(); - - /** - * Sets the current context. - * - * @param context to the new argument (should never be null, although implementations must check if - * null has been passed and throw an IllegalArgumentException in such cases) - */ - void setContext(SecurityContext context); - - /** - * Creates a new, empty context implementation, for use by SecurityContextRepository implementations, - * when creating a new context for the first time. - * - * @return the empty context. - */ - SecurityContext createEmptyContext(); -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.core.context; + +/** + * A strategy for storing security context information against a thread. + * + *

+ * The preferred strategy is loaded by {@link SecurityContextHolder}. + * + * @author Ben Alex + */ +public interface SecurityContextHolderStrategy { + //~ Methods ======================================================================================================== + + /** + * Clears the current context. + */ + void clearContext(); + + /** + * Obtains the current context. + * + * @return a context (never null - create a default implementation if necessary) + */ + SecurityContext getContext(); + + /** + * Sets the current context. + * + * @param context to the new argument (should never be null, although implementations must check if + * null has been passed and throw an IllegalArgumentException in such cases) + */ + void setContext(SecurityContext context); + + /** + * Creates a new, empty context implementation, for use by SecurityContextRepository implementations, + * when creating a new context for the first time. + * + * @return the empty context. + */ + SecurityContext createEmptyContext(); +} diff --git a/core/src/main/java/org/springframework/security/core/context/SecurityContextImpl.java b/core/src/main/java/org/springframework/security/core/context/SecurityContextImpl.java index 036fd81412..6d38bbb907 100644 --- a/core/src/main/java/org/springframework/security/core/context/SecurityContextImpl.java +++ b/core/src/main/java/org/springframework/security/core/context/SecurityContextImpl.java @@ -23,7 +23,6 @@ import org.springframework.security.core.Authentication; * HttpSessionContextIntegrationFilter}.

* * @author Ben Alex - * @version $Id$ */ public class SecurityContextImpl implements SecurityContext { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/core/context/ThreadLocalSecurityContextHolderStrategy.java b/core/src/main/java/org/springframework/security/core/context/ThreadLocalSecurityContextHolderStrategy.java index 1554f8ea75..2791e7a1b7 100644 --- a/core/src/main/java/org/springframework/security/core/context/ThreadLocalSecurityContextHolderStrategy.java +++ b/core/src/main/java/org/springframework/security/core/context/ThreadLocalSecurityContextHolderStrategy.java @@ -1,60 +1,59 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.core.context; - -import org.springframework.util.Assert; - - -/** - * A ThreadLocal-based implementation of {@link SecurityContextHolderStrategy}. - * - * @author Ben Alex - * @version $Id$ - * - * @see java.lang.ThreadLocal - * @see org.springframework.security.core.context.web.SecurityContextPersistenceFilter - */ -final class ThreadLocalSecurityContextHolderStrategy implements SecurityContextHolderStrategy { - //~ Static fields/initializers ===================================================================================== - - private static final ThreadLocal contextHolder = new ThreadLocal(); - - //~ Methods ======================================================================================================== - - public void clearContext() { - contextHolder.set(null); - } - - public SecurityContext getContext() { - SecurityContext ctx = contextHolder.get(); - - if (ctx == null) { - ctx = createEmptyContext(); - contextHolder.set(ctx); - } - - return ctx; - } - - public void setContext(SecurityContext context) { - Assert.notNull(context, "Only non-null SecurityContext instances are permitted"); - contextHolder.set(context); - } - - public SecurityContext createEmptyContext() { - return new SecurityContextImpl(); - } -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.core.context; + +import org.springframework.util.Assert; + + +/** + * A ThreadLocal-based implementation of {@link SecurityContextHolderStrategy}. + * + * @author Ben Alex + * + * @see java.lang.ThreadLocal + * @see org.springframework.security.core.context.web.SecurityContextPersistenceFilter + */ +final class ThreadLocalSecurityContextHolderStrategy implements SecurityContextHolderStrategy { + //~ Static fields/initializers ===================================================================================== + + private static final ThreadLocal contextHolder = new ThreadLocal(); + + //~ Methods ======================================================================================================== + + public void clearContext() { + contextHolder.set(null); + } + + public SecurityContext getContext() { + SecurityContext ctx = contextHolder.get(); + + if (ctx == null) { + ctx = createEmptyContext(); + contextHolder.set(ctx); + } + + return ctx; + } + + public void setContext(SecurityContext context) { + Assert.notNull(context, "Only non-null SecurityContext instances are permitted"); + contextHolder.set(context); + } + + public SecurityContext createEmptyContext() { + return new SecurityContextImpl(); + } +} diff --git a/core/src/main/java/org/springframework/security/core/session/SessionCreationEvent.java b/core/src/main/java/org/springframework/security/core/session/SessionCreationEvent.java index 600990b036..d0d7108bb5 100644 --- a/core/src/main/java/org/springframework/security/core/session/SessionCreationEvent.java +++ b/core/src/main/java/org/springframework/security/core/session/SessionCreationEvent.java @@ -7,7 +7,6 @@ import org.springframework.context.ApplicationEvent; * represented by a security context) has begun. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public abstract class SessionCreationEvent extends ApplicationEvent { diff --git a/core/src/main/java/org/springframework/security/core/session/SessionDestroyedEvent.java b/core/src/main/java/org/springframework/security/core/session/SessionDestroyedEvent.java index 76b77e1fb6..6c66a0002d 100644 --- a/core/src/main/java/org/springframework/security/core/session/SessionDestroyedEvent.java +++ b/core/src/main/java/org/springframework/security/core/session/SessionDestroyedEvent.java @@ -8,7 +8,6 @@ import org.springframework.security.core.context.SecurityContext; * represented by a security context) has ended. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public abstract class SessionDestroyedEvent extends ApplicationEvent { diff --git a/core/src/main/java/org/springframework/security/core/session/SessionIdentifierAware.java b/core/src/main/java/org/springframework/security/core/session/SessionIdentifierAware.java index 417205c7a8..98e0272931 100644 --- a/core/src/main/java/org/springframework/security/core/session/SessionIdentifierAware.java +++ b/core/src/main/java/org/springframework/security/core/session/SessionIdentifierAware.java @@ -30,7 +30,6 @@ package org.springframework.security.core.session; *

* * @author Ben Alex - * @version $Id$ */ public interface SessionIdentifierAware { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/session/SessionInformation.java b/core/src/main/java/org/springframework/security/core/session/SessionInformation.java index de1db8bab7..9cc142c401 100644 --- a/core/src/main/java/org/springframework/security/core/session/SessionInformation.java +++ b/core/src/main/java/org/springframework/security/core/session/SessionInformation.java @@ -33,7 +33,6 @@ import java.io.Serializable; * reached). An "expired" session is removed as soon as possible by a Filter. * * @author Ben Alex - * @version $Id$ */ public class SessionInformation implements Serializable { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/core/session/SessionRegistry.java b/core/src/main/java/org/springframework/security/core/session/SessionRegistry.java index 9496b923a4..230b77bf37 100644 --- a/core/src/main/java/org/springframework/security/core/session/SessionRegistry.java +++ b/core/src/main/java/org/springframework/security/core/session/SessionRegistry.java @@ -21,7 +21,6 @@ import java.util.List; * Maintains a registry of SessionInformation instances. * * @author Ben Alex - * @version $Id$ */ public interface SessionRegistry { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/session/SessionRegistryImpl.java b/core/src/main/java/org/springframework/security/core/session/SessionRegistryImpl.java index d73e0c60c1..39e8f22c7a 100644 --- a/core/src/main/java/org/springframework/security/core/session/SessionRegistryImpl.java +++ b/core/src/main/java/org/springframework/security/core/session/SessionRegistryImpl.java @@ -40,7 +40,6 @@ import org.springframework.util.Assert; * * @author Ben Alex * @author Luke Taylor - * @version $Id$ */ public class SessionRegistryImpl implements SessionRegistry, ApplicationListener { diff --git a/core/src/main/java/org/springframework/security/core/token/DefaultToken.java b/core/src/main/java/org/springframework/security/core/token/DefaultToken.java index c7c05086b9..6bdd655096 100644 --- a/core/src/main/java/org/springframework/security/core/token/DefaultToken.java +++ b/core/src/main/java/org/springframework/security/core/token/DefaultToken.java @@ -6,7 +6,7 @@ import org.springframework.util.Assert; /** * The default implementation of {@link Token}. - * + * * @author Ben Alex * @since 2.0.1 */ @@ -14,7 +14,7 @@ public class DefaultToken implements Token { private String key; private long keyCreationTime; private String extendedInformation; - + public DefaultToken(String key, long keyCreationTime, String extendedInformation) { Assert.hasText(key, "Key required"); Assert.notNull(extendedInformation, "Extended information cannot be null"); @@ -26,7 +26,7 @@ public class DefaultToken implements Token { public String getKey() { return key; } - + public long getKeyCreationTime() { return keyCreationTime; } @@ -54,6 +54,6 @@ public class DefaultToken implements Token { public String toString() { return "DefaultToken[key=" + new String(key) + "; creation=" + new Date(keyCreationTime) + "; extended=" + extendedInformation + "]"; } - - + + } diff --git a/core/src/main/java/org/springframework/security/core/token/SecureRandomFactoryBean.java b/core/src/main/java/org/springframework/security/core/token/SecureRandomFactoryBean.java index a0884e77d5..fdc5a1462e 100644 --- a/core/src/main/java/org/springframework/security/core/token/SecureRandomFactoryBean.java +++ b/core/src/main/java/org/springframework/security/core/token/SecureRandomFactoryBean.java @@ -13,7 +13,6 @@ import org.springframework.util.FileCopyUtils; * * @author Ben Alex * @since 2.0.1 - * @version $Id$ */ public class SecureRandomFactoryBean implements FactoryBean { diff --git a/core/src/main/java/org/springframework/security/core/token/Token.java b/core/src/main/java/org/springframework/security/core/token/Token.java index 94d64ee433..3cf22b7020 100644 --- a/core/src/main/java/org/springframework/security/core/token/Token.java +++ b/core/src/main/java/org/springframework/security/core/token/Token.java @@ -3,7 +3,7 @@ package org.springframework.security.core.token; /** * A token issued by {@link TokenService}. - * + * *

* It is important that the keys assigned to tokens are sufficiently randomised and secured that * they can serve as identifying a unique user session. Implementations of {@link TokenService} @@ -11,34 +11,34 @@ package org.springframework.security.core.token; * keys are of sufficient length to balance safety against persistence cost. In relation to persistence * cost, it is strongly recommended that returned keys are small enough for encoding in a cookie. *

- * + * * @author Ben Alex * @since 2.0.1 */ public interface Token { - + /** * Obtains the randomised, secure key assigned to this token. Presentation of this token to * {@link TokenService} will always return a Token that is equal to the original * Token issued for that key. - * + * * @return a key with appropriate randomness and security. */ String getKey(); - + /** * The time the token key was initially created is available from this method. Note that a given * token must never have this creation time changed. If necessary, a new token can be * requested from the {@link TokenService} to replace the original token. - * + * * @return the time this token key was created, in the same format as specified by {@link Date#getTime()). */ - long getKeyCreationTime(); - + long getKeyCreationTime(); + /** * Obtains the extended information associated within the token, which was presented when the token * was first created. - * + * * @return the user-specified extended information, if any */ String getExtendedInformation(); diff --git a/core/src/main/java/org/springframework/security/core/token/TokenService.java b/core/src/main/java/org/springframework/security/core/token/TokenService.java index 63c50ac6c4..5101cc5917 100644 --- a/core/src/main/java/org/springframework/security/core/token/TokenService.java +++ b/core/src/main/java/org/springframework/security/core/token/TokenService.java @@ -3,7 +3,7 @@ package org.springframework.security.core.token; /** * Provides a mechanism to allocate and rebuild secure, randomised tokens. - * + * *

* Implementations are solely concern with issuing a new {@link Token} on demand. The * issued Token may contain user-specified extended information. The token also @@ -12,7 +12,7 @@ package org.springframework.security.core.token; * to the TokenService for verification and reconstruction of a Token * equal to the original Token. *

- * + * *

* Given the tightly-focused behaviour provided by this interface, it can serve as a building block * for more sophisticated token-based solutions. For example, authentication systems that depend on @@ -20,7 +20,7 @@ package org.springframework.security.core.token; * extended information associated with the key). It is important to recognise that we do not intend * for this interface to be expanded to provide such capabilities directly. *

- * + * * @author Ben Alex * @since 2.0.1 * @@ -28,17 +28,17 @@ package org.springframework.security.core.token; public interface TokenService { /** * Forces the allocation of a new {@link Token}. - * + * * @param the extended information desired in the token (cannot be null, but can be empty) * @return a new token that has not been issued previously, and is guaranteed to be recognised * by this implementation's {@link #verifyToken(String)} at any future time. */ Token allocateToken(String extendedInformation); - + /** * Permits verification the <{@link Token#getKey()} was issued by this TokenService and * reconstructs the corresponding Token. - * + * * @param key as obtained from {@link Token#getKey()} and created by this implementation * @return the token, or null if the token was not issued by this TokenService */ diff --git a/core/src/main/java/org/springframework/security/core/userdetails/AuthenticationUserDetailsService.java b/core/src/main/java/org/springframework/security/core/userdetails/AuthenticationUserDetailsService.java index 46c496d6c5..56d10d9205 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/AuthenticationUserDetailsService.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/AuthenticationUserDetailsService.java @@ -1,24 +1,23 @@ -package org.springframework.security.core.userdetails; - -import org.springframework.security.core.Authentication; - - -/** - * Interface that allows for retrieving a UserDetails object based on an Authentication object. - * - * @author Ruud Senden - * @version $Id$ - * @since 2.0 - */ -public interface AuthenticationUserDetailsService { - - /** - * - * @param token The pre-authenticated authentication token - * @return UserDetails for the given authentication token, never null. - * @throws UsernameNotFoundException - * if no user details can be found for the given authentication - * token - */ - UserDetails loadUserDetails(Authentication token) throws UsernameNotFoundException; -} +package org.springframework.security.core.userdetails; + +import org.springframework.security.core.Authentication; + + +/** + * Interface that allows for retrieving a UserDetails object based on an Authentication object. + * + * @author Ruud Senden + * @since 2.0 + */ +public interface AuthenticationUserDetailsService { + + /** + * + * @param token The pre-authenticated authentication token + * @return UserDetails for the given authentication token, never null. + * @throws UsernameNotFoundException + * if no user details can be found for the given authentication + * token + */ + UserDetails loadUserDetails(Authentication token) throws UsernameNotFoundException; +} diff --git a/core/src/main/java/org/springframework/security/core/userdetails/User.java b/core/src/main/java/org/springframework/security/core/userdetails/User.java index 9c7b99efc5..5932171ab2 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/User.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/User.java @@ -35,7 +35,6 @@ import org.springframework.util.Assert; * scratch. * * @author Ben Alex - * @version $Id$ */ public class User implements UserDetails { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/core/userdetails/UserCache.java b/core/src/main/java/org/springframework/security/core/userdetails/UserCache.java index 68a17df0ec..02503891be 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/UserCache.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/UserCache.java @@ -33,7 +33,6 @@ package org.springframework.security.core.userdetails; * @see {@link org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider} * * @author Ben Alex - * @version $Id$ */ public interface UserCache { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/userdetails/UserDetails.java b/core/src/main/java/org/springframework/security/core/userdetails/UserDetails.java index 05a1bfb942..689c17d018 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/UserDetails.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/UserDetails.java @@ -50,7 +50,6 @@ import java.util.Collection; * @see UserCache * * @author Ben Alex - * @version $Id$ */ public interface UserDetails extends Serializable { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapper.java b/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapper.java index de235874ec..44118df738 100755 --- a/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapper.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapper.java @@ -1,65 +1,65 @@ -package org.springframework.security.core.userdetails; - -import org.springframework.security.core.Authentication; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.dao.DataAccessException; -import org.springframework.util.Assert; - -/** - * This implementation for AuthenticationUserDetailsService wraps a regular - * Spring Security UserDetailsService implementation, to retrieve a UserDetails object - * based on the user name contained in an Authentication object. - * - * @author Ruud Senden - * @author Scott Battaglia - * @since 2.0 - */ -public class UserDetailsByNameServiceWrapper implements AuthenticationUserDetailsService, InitializingBean { - private UserDetailsService userDetailsService = null; - - /** - * Constructs an empty wrapper for compatibility with Spring Security 2.0.x's method of using a setter. - */ - public UserDetailsByNameServiceWrapper() { - // constructor for backwards compatibility with 2.0 - } - - /** - * Constructs a new wrapper using the supplied {@link org.springframework.security.core.userdetails.UserDetailsService} - * as the service to delegate to. - * - * @param userDetailsService the UserDetailsService to delegate to. - */ - public UserDetailsByNameServiceWrapper(final UserDetailsService userDetailsService) { - Assert.notNull(userDetailsService, "userDetailsService cannot be null."); - this.userDetailsService = userDetailsService; - } - - /** - * Check whether all required properties have been set. - * - * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() - */ - public void afterPropertiesSet() throws Exception { - Assert.notNull(this.userDetailsService, "UserDetailsService must be set"); - } - - /** - * Get the UserDetails object from the wrapped UserDetailsService - * implementation - */ - public UserDetails loadUserDetails(Authentication authentication) throws UsernameNotFoundException, - DataAccessException { - return this.userDetailsService.loadUserByUsername(authentication.getName()); - } - - /** - * Set the wrapped UserDetailsService implementation - * - * @param aUserDetailsService - * The wrapped UserDetailsService to set - */ - public void setUserDetailsService(UserDetailsService aUserDetailsService) { - this.userDetailsService = aUserDetailsService; - } -} +package org.springframework.security.core.userdetails; + +import org.springframework.security.core.Authentication; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.dao.DataAccessException; +import org.springframework.util.Assert; + +/** + * This implementation for AuthenticationUserDetailsService wraps a regular + * Spring Security UserDetailsService implementation, to retrieve a UserDetails object + * based on the user name contained in an Authentication object. + * + * @author Ruud Senden + * @author Scott Battaglia + * @since 2.0 + */ +public class UserDetailsByNameServiceWrapper implements AuthenticationUserDetailsService, InitializingBean { + private UserDetailsService userDetailsService = null; + + /** + * Constructs an empty wrapper for compatibility with Spring Security 2.0.x's method of using a setter. + */ + public UserDetailsByNameServiceWrapper() { + // constructor for backwards compatibility with 2.0 + } + + /** + * Constructs a new wrapper using the supplied {@link org.springframework.security.core.userdetails.UserDetailsService} + * as the service to delegate to. + * + * @param userDetailsService the UserDetailsService to delegate to. + */ + public UserDetailsByNameServiceWrapper(final UserDetailsService userDetailsService) { + Assert.notNull(userDetailsService, "userDetailsService cannot be null."); + this.userDetailsService = userDetailsService; + } + + /** + * Check whether all required properties have been set. + * + * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() + */ + public void afterPropertiesSet() throws Exception { + Assert.notNull(this.userDetailsService, "UserDetailsService must be set"); + } + + /** + * Get the UserDetails object from the wrapped UserDetailsService + * implementation + */ + public UserDetails loadUserDetails(Authentication authentication) throws UsernameNotFoundException, + DataAccessException { + return this.userDetailsService.loadUserByUsername(authentication.getName()); + } + + /** + * Set the wrapped UserDetailsService implementation + * + * @param aUserDetailsService + * The wrapped UserDetailsService to set + */ + public void setUserDetailsService(UserDetailsService aUserDetailsService) { + this.userDetailsService = aUserDetailsService; + } +} diff --git a/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsChecker.java b/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsChecker.java index 1e53f5daba..290d3c69d0 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsChecker.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsChecker.java @@ -10,7 +10,6 @@ package org.springframework.security.core.userdetails; * It should not involved in making any authentication decisions based on a submitted authentication request. * * @author Luke Taylor - * @version $Id$ * @since 2.0 * * @see org.springframework.security.authentication.AccountStatusUserDetailsChecker diff --git a/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsService.java b/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsService.java index 499942ea1b..63975ce380 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsService.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/UserDetailsService.java @@ -31,7 +31,6 @@ import org.springframework.dao.DataAccessException; * @see UserDetails * * @author Ben Alex - * @version $Id$ */ public interface UserDetailsService { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/userdetails/UsernameNotFoundException.java b/core/src/main/java/org/springframework/security/core/userdetails/UsernameNotFoundException.java index b5c833341d..30080cbb2c 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/UsernameNotFoundException.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/UsernameNotFoundException.java @@ -22,7 +22,6 @@ import org.springframework.security.core.AuthenticationException; * Thrown if an {@link UserDetailsService} implementation cannot locate a {@link User} by its username. * * @author Ben Alex - * @version $Id$ */ public class UsernameNotFoundException extends AuthenticationException { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCache.java b/core/src/main/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCache.java index 4fc745a8c6..7c729abc56 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCache.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCache.java @@ -38,7 +38,6 @@ import org.springframework.util.Assert; * HREF="http://ehcache.sourceforge.net">EHCACHE
. * * @author Ben Alex - * @version $Id$ */ public class EhCacheBasedUserCache implements UserCache, InitializingBean { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/userdetails/cache/NullUserCache.java b/core/src/main/java/org/springframework/security/core/userdetails/cache/NullUserCache.java index 3436ae4eed..7fa5586a97 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/cache/NullUserCache.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/cache/NullUserCache.java @@ -24,7 +24,6 @@ import org.springframework.security.core.userdetails.UserDetails; * Does not perform any caching. * * @author Ben Alex - * @version $Id$ */ public class NullUserCache implements UserCache { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImpl.java b/core/src/main/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImpl.java index 103599900a..032c5990d2 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImpl.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImpl.java @@ -90,7 +90,6 @@ import org.springframework.util.Assert; * @author Ben Alex * @author colin sampaleanu * @author Luke Taylor - * @version $Id$ */ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/userdetails/memory/InMemoryDaoImpl.java b/core/src/main/java/org/springframework/security/core/userdetails/memory/InMemoryDaoImpl.java index 30eb427df6..194ad1acfd 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/memory/InMemoryDaoImpl.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/memory/InMemoryDaoImpl.java @@ -32,7 +32,6 @@ import java.util.Properties; * Retrieves user details from an in-memory list created by the bean context. * * @author Ben Alex - * @version $Id$ */ public class InMemoryDaoImpl implements UserDetailsService, InitializingBean { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/core/userdetails/memory/UserAttribute.java b/core/src/main/java/org/springframework/security/core/userdetails/memory/UserAttribute.java index d88756ac55..3f67100e0f 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/memory/UserAttribute.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/memory/UserAttribute.java @@ -27,7 +27,6 @@ import org.springframework.security.core.authority.GrantedAuthorityImpl; * Used by {@link InMemoryDaoImpl} to temporarily store the attributes associated with a user. * * @author Ben Alex - * @version $Id$ */ public class UserAttribute { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/core/userdetails/memory/UserAttributeEditor.java b/core/src/main/java/org/springframework/security/core/userdetails/memory/UserAttributeEditor.java index 0cd83f6bd4..a343df84c7 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/memory/UserAttributeEditor.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/memory/UserAttributeEditor.java @@ -25,7 +25,6 @@ import org.springframework.util.StringUtils; * Property editor that creates a {@link UserAttribute} from a comma separated list of values. * * @author Ben Alex - * @version $Id$ */ public class UserAttributeEditor extends PropertyEditorSupport { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/userdetails/memory/UserMap.java b/core/src/main/java/org/springframework/security/core/userdetails/memory/UserMap.java index 8c92933126..2554d2762b 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/memory/UserMap.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/memory/UserMap.java @@ -29,7 +29,6 @@ import org.springframework.util.Assert; * Used by {@link InMemoryDaoImpl} to store a list of users and their corresponding granted authorities. * * @author Ben Alex - * @version $Id$ */ public class UserMap { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/main/java/org/springframework/security/core/userdetails/memory/UserMapEditor.java b/core/src/main/java/org/springframework/security/core/userdetails/memory/UserMapEditor.java index cc915af583..2e531fa836 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/memory/UserMapEditor.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/memory/UserMapEditor.java @@ -40,7 +40,6 @@ import java.util.Properties; * does honour the user enabled/disabled flag as described above.

* * @author Ben Alex - * @version $Id$ */ public class UserMapEditor extends PropertyEditorSupport { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/provisioning/GroupManager.java b/core/src/main/java/org/springframework/security/provisioning/GroupManager.java index 1cf5f68337..3f8da56bd1 100644 --- a/core/src/main/java/org/springframework/security/provisioning/GroupManager.java +++ b/core/src/main/java/org/springframework/security/provisioning/GroupManager.java @@ -15,7 +15,6 @@ import org.springframework.security.core.GrantedAuthority; * are assigned to the group, providing more flexible administration options. * * @author Luke Taylor - * @version $Id$ */ public interface GroupManager { diff --git a/core/src/main/java/org/springframework/security/provisioning/JdbcUserDetailsManager.java b/core/src/main/java/org/springframework/security/provisioning/JdbcUserDetailsManager.java index 94d0112fc9..7291accbd8 100644 --- a/core/src/main/java/org/springframework/security/provisioning/JdbcUserDetailsManager.java +++ b/core/src/main/java/org/springframework/security/provisioning/JdbcUserDetailsManager.java @@ -38,7 +38,6 @@ import java.util.List; * it's important that you take this into account when using this implementation for managing your users. * * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsManager, GroupManager { diff --git a/core/src/main/java/org/springframework/security/provisioning/UserDetailsManager.java b/core/src/main/java/org/springframework/security/provisioning/UserDetailsManager.java index baa0bf27f4..c9ec100027 100644 --- a/core/src/main/java/org/springframework/security/provisioning/UserDetailsManager.java +++ b/core/src/main/java/org/springframework/security/provisioning/UserDetailsManager.java @@ -1,46 +1,45 @@ -package org.springframework.security.provisioning; - -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; - -/** - * An extension of the {@link UserDetailsService} which provides the ability - * to create new users and update existing ones. - * - * @author Luke Taylor - * @since 2.0 - * @version $Id$ - */ -public interface UserDetailsManager extends UserDetailsService { - - /** - * Create a new user with the supplied details. - */ - void createUser(UserDetails user); - - /** - * Update the specified user. - */ - void updateUser(UserDetails user); - - /** - * Remove the user with the given login name from the system. - */ - void deleteUser(String username); - - /** - * Modify the current user's password. This should change the user's password in - * the persistent user repository (datbase, LDAP etc) and should also modify the - * current security context to contain the new password. - * - * @param oldPassword current password (for re-authentication if required) - * @param newPassword the password to change to - */ - void changePassword(String oldPassword, String newPassword); - - /** - * Check if a user with the supplied login name exists in the system. - */ - boolean userExists(String username); - -} +package org.springframework.security.provisioning; + +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; + +/** + * An extension of the {@link UserDetailsService} which provides the ability + * to create new users and update existing ones. + * + * @author Luke Taylor + * @since 2.0 + */ +public interface UserDetailsManager extends UserDetailsService { + + /** + * Create a new user with the supplied details. + */ + void createUser(UserDetails user); + + /** + * Update the specified user. + */ + void updateUser(UserDetails user); + + /** + * Remove the user with the given login name from the system. + */ + void deleteUser(String username); + + /** + * Modify the current user's password. This should change the user's password in + * the persistent user repository (datbase, LDAP etc) and should also modify the + * current security context to contain the new password. + * + * @param oldPassword current password (for re-authentication if required) + * @param newPassword the password to change to + */ + void changePassword(String oldPassword, String newPassword); + + /** + * Check if a user with the supplied login name exists in the system. + */ + boolean userExists(String username); + +} diff --git a/core/src/main/java/org/springframework/security/remoting/dns/DnsEntryNotFoundException.java b/core/src/main/java/org/springframework/security/remoting/dns/DnsEntryNotFoundException.java index b16c3d0890..7410b72bd7 100644 --- a/core/src/main/java/org/springframework/security/remoting/dns/DnsEntryNotFoundException.java +++ b/core/src/main/java/org/springframework/security/remoting/dns/DnsEntryNotFoundException.java @@ -22,7 +22,6 @@ package org.springframework.security.remoting.dns; * * @author Mike Wiesner * @since 3.0 - * @version $Id$ */ public class DnsEntryNotFoundException extends DnsLookupException { diff --git a/core/src/main/java/org/springframework/security/remoting/dns/DnsLookupException.java b/core/src/main/java/org/springframework/security/remoting/dns/DnsLookupException.java index 3913a8e13e..f70f11aef0 100644 --- a/core/src/main/java/org/springframework/security/remoting/dns/DnsLookupException.java +++ b/core/src/main/java/org/springframework/security/remoting/dns/DnsLookupException.java @@ -23,7 +23,6 @@ import org.springframework.dao.DataAccessException; * * @author Mike Wiesner * @since 3.0 - * @version $Id$ */ public class DnsLookupException extends DataAccessException { diff --git a/core/src/main/java/org/springframework/security/remoting/dns/DnsResolver.java b/core/src/main/java/org/springframework/security/remoting/dns/DnsResolver.java index 1184182c20..cfa558bb26 100644 --- a/core/src/main/java/org/springframework/security/remoting/dns/DnsResolver.java +++ b/core/src/main/java/org/springframework/security/remoting/dns/DnsResolver.java @@ -21,7 +21,6 @@ package org.springframework.security.remoting.dns; * * @author Mike Wiesner * @since 3.0 - * @version $Id$ */ public interface DnsResolver { diff --git a/core/src/main/java/org/springframework/security/remoting/dns/InitialContextFactory.java b/core/src/main/java/org/springframework/security/remoting/dns/InitialContextFactory.java index 2587a9f947..da8c030edb 100644 --- a/core/src/main/java/org/springframework/security/remoting/dns/InitialContextFactory.java +++ b/core/src/main/java/org/springframework/security/remoting/dns/InitialContextFactory.java @@ -25,7 +25,6 @@ import javax.naming.directory.InitialDirContext; * * @author Mike Wiesner * @since 3.0 - * @version $Id$ * @see InitialDirContext * @see DirContext * @see JndiDnsResolver diff --git a/core/src/main/java/org/springframework/security/remoting/dns/JndiDnsResolver.java b/core/src/main/java/org/springframework/security/remoting/dns/JndiDnsResolver.java index af85bc7c76..1f51c91961 100644 --- a/core/src/main/java/org/springframework/security/remoting/dns/JndiDnsResolver.java +++ b/core/src/main/java/org/springframework/security/remoting/dns/JndiDnsResolver.java @@ -36,7 +36,6 @@ import javax.naming.directory.InitialDirContext; * * @author Mike Wiesner * @since 3.0 - * @version $Id$ * @see DnsResolver * @see InitialContextFactory */ diff --git a/core/src/main/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutor.java b/core/src/main/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutor.java index 5945a80bf8..6bde4a9742 100644 --- a/core/src/main/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutor.java +++ b/core/src/main/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutor.java @@ -30,7 +30,6 @@ import org.springframework.security.core.context.SecurityContextHolder; * Adds BASIC authentication support to SimpleHttpInvokerRequestExecutor. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationSimpleHttpInvokerRequestExecutor extends SimpleHttpInvokerRequestExecutor { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/main/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocation.java b/core/src/main/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocation.java index 5cbccf4fde..3822e4547f 100644 --- a/core/src/main/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocation.java +++ b/core/src/main/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocation.java @@ -41,7 +41,6 @@ import java.lang.reflect.InvocationTargetException; * * @author James Monaghan * @author Ben Alex - * @version $Id$ */ public class ContextPropagatingRemoteInvocation extends RemoteInvocation { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/main/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocationFactory.java b/core/src/main/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocationFactory.java index 7314dd0aa7..300ae3e324 100644 --- a/core/src/main/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocationFactory.java +++ b/core/src/main/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocationFactory.java @@ -28,7 +28,6 @@ import org.springframework.remoting.support.RemoteInvocationFactory; * * @author James Monaghan * @author Ben Alex - * @version $Id$ */ public class ContextPropagatingRemoteInvocationFactory implements RemoteInvocationFactory { //~ Methods ======================================================================================================== diff --git a/core/src/main/java/org/springframework/security/util/EncryptionUtils.java b/core/src/main/java/org/springframework/security/util/EncryptionUtils.java index 7b5945f62f..c560a2aa95 100644 --- a/core/src/main/java/org/springframework/security/util/EncryptionUtils.java +++ b/core/src/main/java/org/springframework/security/util/EncryptionUtils.java @@ -36,7 +36,6 @@ import org.springframework.util.Assert; * * @author Alan Stewart * @author Ben Alex - * @version $Id$ */ public final class EncryptionUtils { diff --git a/core/src/main/java/org/springframework/security/util/FieldUtils.java b/core/src/main/java/org/springframework/security/util/FieldUtils.java index 877e12722d..6387a7fa9f 100644 --- a/core/src/main/java/org/springframework/security/util/FieldUtils.java +++ b/core/src/main/java/org/springframework/security/util/FieldUtils.java @@ -26,7 +26,6 @@ import java.lang.reflect.Field; * Offers static methods for directly manipulating static fields. * * @author Ben Alex - * @version $Id$ */ public final class FieldUtils { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/util/InMemoryResource.java b/core/src/main/java/org/springframework/security/util/InMemoryResource.java index 50c9f4ff20..b59553651c 100644 --- a/core/src/main/java/org/springframework/security/util/InMemoryResource.java +++ b/core/src/main/java/org/springframework/security/util/InMemoryResource.java @@ -29,7 +29,6 @@ import java.util.Arrays; *

Used to create a bean factory from an XML string, rather than a file.

* * @author Luke Taylor - * @version $Id$ */ public class InMemoryResource extends AbstractResource { //~ Instance fields ================================================================================================ diff --git a/core/src/main/java/org/springframework/security/util/MethodInvocationUtils.java b/core/src/main/java/org/springframework/security/util/MethodInvocationUtils.java index 335ea1a462..99a079ae45 100644 --- a/core/src/main/java/org/springframework/security/util/MethodInvocationUtils.java +++ b/core/src/main/java/org/springframework/security/util/MethodInvocationUtils.java @@ -29,7 +29,6 @@ import org.springframework.util.Assert; * All methods of this class return a {@link org.springframework.security.util.SimpleMethodInvocation}. * * @author Ben Alex - * @version $Id$ */ public final class MethodInvocationUtils { //~ Constructors =================================================================================================== diff --git a/core/src/main/java/org/springframework/security/util/SimpleMethodInvocation.java b/core/src/main/java/org/springframework/security/util/SimpleMethodInvocation.java index 14578f52b0..967ffa756b 100644 --- a/core/src/main/java/org/springframework/security/util/SimpleMethodInvocation.java +++ b/core/src/main/java/org/springframework/security/util/SimpleMethodInvocation.java @@ -25,7 +25,6 @@ import java.lang.reflect.Method; * Represents the AOP Alliance MethodInvocation. * * @author Ben Alex - * @version $Id$ */ public class SimpleMethodInvocation implements MethodInvocation { //~ Instance fields ================================================================================================ diff --git a/core/src/main/resources/org/springframework/security/messages_fr.properties b/core/src/main/resources/org/springframework/security/messages_fr.properties index 9ac4dbda26..bbbabf7fbc 100644 --- a/core/src/main/resources/org/springframework/security/messages_fr.properties +++ b/core/src/main/resources/org/springframework/security/messages_fr.properties @@ -1,45 +1,45 @@ -# Spring security -# Messages in French -# Translation by Laurent Pireyn (laurent.pireyn@pisolutions.eu) - -AuthByAdapterProvider.incorrectKey = L'implémentation de AuthByAdapter présentée ne contient pas la clé attendue -BasicAclEntryAfterInvocationProvider.noPermission = L'authentification {0} n'a AUCUNE permission pour l'objet domaine {1} -BasicAclEntryAfterInvocationProvider.insufficientPermission = L'authentification {0} a des permissions ACL pour l'objet domaine, mais pas la permission ACL requise pour l'objet domaine {1} -ConcurrentSessionControllerImpl.exceededAllowed = Le maximum de {0} sessions a été dépassé pour cet utilisateur -ProviderManager.providerNotFound = Aucun AuthenticationProvider n'a été trouvé pour {0} -AnonymousAuthenticationProvider.incorrectKey = L'AnonymousAuthenticationToken présenté ne contient pas la clé attendue -CasAuthenticationProvider.incorrectKey = Le CasAuthenticationToken présenté ne contient pas la clé attendue -CasAuthenticationProvider.noServiceTicket = Echec d'obtention d'un ticket CAS à valider -NamedCasProxyDecider.untrusted = Le proxy {0} le plus proche n'est pas fiable -RejectProxyTickets.reject = Des tickets proxy ont été rejetés -AbstractSecurityInterceptor.authenticationNotFound = Aucun objet Authentication n'a été trouvé dans le SecurityContext -AbstractUserDetailsAuthenticationProvider.onlySupports = Seul UsernamePasswordAuthenticationToken est pris en charge -AbstractUserDetailsAuthenticationProvider.locked = Le compte utilisateur est bloqué -AbstractUserDetailsAuthenticationProvider.disabled = Le compte utilisateur est désactivé -AbstractUserDetailsAuthenticationProvider.expired = Le compte utilisateur a expiré -AbstractUserDetailsAuthenticationProvider.credentialsExpired = Les créances de l'utilisateur ont expiré -AbstractUserDetailsAuthenticationProvider.badCredentials = Les créances sont erronées -X509AuthenticationProvider.certificateNull = Le certificat est null -DaoX509AuthoritiesPopulator.noMatching = Aucun motif concordant n'a été trouvé dans le subjectDN: {0} -RememberMeAuthenticationProvider.incorrectKey = Le RememberMeAuthenticationToken présenté ne contient pas la clé attendue -RunAsImplAuthenticationProvider.incorrectKey = Le RunAsUserToken présenté ne contient pas la clé attendue -DigestProcessingFilter.missingMandatory = Une valeur obligatoire manque au condensé; reçu l'entête {0} -DigestProcessingFilter.missingAuth = Une valeur obligatoire manque au condensé pour 'auth' QOP; reçu l'entête {0} -DigestProcessingFilter.incorrectRealm = Le nom de domaine de la réponse {0} ne correspond pas au nom de domaine du système {1} -DigestProcessingFilter.nonceExpired = Le nonce a expiré -DigestProcessingFilter.nonceEncoding = Le nonce n'est pas encodé en Base64; reçu le nonce {0} -DigestProcessingFilter.nonceNotTwoTokens = Le nonce aurait dû générer deux jetons, mais était {0} -DigestProcessingFilter.nonceNotNumeric = Le jeton nonce aurait dû générer d'abord un jeton numérique, mais était {0} -DigestProcessingFilter.nonceCompromised = Le jeton nonce est compromis {0} -DigestProcessingFilter.usernameNotFound = Le nom d'utilisateur {0} n'a pas été trouvé -DigestProcessingFilter.incorrectResponse = Réponse incorrecte -JdbcDaoImpl.notFound=Le nom d'utilisateur {0} n'a pas été trouvé -JdbcDaoImpl.noAuthority=Le compte utilisateur {0} n'a pas de permissions -SwitchUserProcessingFilter.noCurrentUser = Aucun utilisateur n'est associé à la requête en cours -SwitchUserProcessingFilter.noOriginalAuthentication = L'objet Authentication original n'a pas été trouvé -SwitchUserProcessingFilter.usernameNotFound = Le nom d'utilisateur {0} n'a pas été trouvé -SwitchUserProcessingFilter.locked = Le compte utilisateur est bloqué -SwitchUserProcessingFilter.disabled = Le compte utilisateur est désactivé -SwitchUserProcessingFilter.expired = Le compte utilisateur a expiré -SwitchUserProcessingFilter.credentialsExpired = Les créances de l'utilisateur ont expiré -AbstractAccessDecisionManager.accessDenied = Accès refusé +# Spring security +# Messages in French +# Translation by Laurent Pireyn (laurent.pireyn@pisolutions.eu) + +AuthByAdapterProvider.incorrectKey = L'implémentation de AuthByAdapter présentée ne contient pas la clé attendue +BasicAclEntryAfterInvocationProvider.noPermission = L'authentification {0} n'a AUCUNE permission pour l'objet domaine {1} +BasicAclEntryAfterInvocationProvider.insufficientPermission = L'authentification {0} a des permissions ACL pour l'objet domaine, mais pas la permission ACL requise pour l'objet domaine {1} +ConcurrentSessionControllerImpl.exceededAllowed = Le maximum de {0} sessions a été dépassé pour cet utilisateur +ProviderManager.providerNotFound = Aucun AuthenticationProvider n'a été trouvé pour {0} +AnonymousAuthenticationProvider.incorrectKey = L'AnonymousAuthenticationToken présenté ne contient pas la clé attendue +CasAuthenticationProvider.incorrectKey = Le CasAuthenticationToken présenté ne contient pas la clé attendue +CasAuthenticationProvider.noServiceTicket = Echec d'obtention d'un ticket CAS à valider +NamedCasProxyDecider.untrusted = Le proxy {0} le plus proche n'est pas fiable +RejectProxyTickets.reject = Des tickets proxy ont été rejetés +AbstractSecurityInterceptor.authenticationNotFound = Aucun objet Authentication n'a été trouvé dans le SecurityContext +AbstractUserDetailsAuthenticationProvider.onlySupports = Seul UsernamePasswordAuthenticationToken est pris en charge +AbstractUserDetailsAuthenticationProvider.locked = Le compte utilisateur est bloqué +AbstractUserDetailsAuthenticationProvider.disabled = Le compte utilisateur est désactivé +AbstractUserDetailsAuthenticationProvider.expired = Le compte utilisateur a expiré +AbstractUserDetailsAuthenticationProvider.credentialsExpired = Les créances de l'utilisateur ont expiré +AbstractUserDetailsAuthenticationProvider.badCredentials = Les créances sont erronées +X509AuthenticationProvider.certificateNull = Le certificat est null +DaoX509AuthoritiesPopulator.noMatching = Aucun motif concordant n'a été trouvé dans le subjectDN: {0} +RememberMeAuthenticationProvider.incorrectKey = Le RememberMeAuthenticationToken présenté ne contient pas la clé attendue +RunAsImplAuthenticationProvider.incorrectKey = Le RunAsUserToken présenté ne contient pas la clé attendue +DigestProcessingFilter.missingMandatory = Une valeur obligatoire manque au condensé; reçu l'entête {0} +DigestProcessingFilter.missingAuth = Une valeur obligatoire manque au condensé pour 'auth' QOP; reçu l'entête {0} +DigestProcessingFilter.incorrectRealm = Le nom de domaine de la réponse {0} ne correspond pas au nom de domaine du système {1} +DigestProcessingFilter.nonceExpired = Le nonce a expiré +DigestProcessingFilter.nonceEncoding = Le nonce n'est pas encodé en Base64; reçu le nonce {0} +DigestProcessingFilter.nonceNotTwoTokens = Le nonce aurait dû générer deux jetons, mais était {0} +DigestProcessingFilter.nonceNotNumeric = Le jeton nonce aurait dû générer d'abord un jeton numérique, mais était {0} +DigestProcessingFilter.nonceCompromised = Le jeton nonce est compromis {0} +DigestProcessingFilter.usernameNotFound = Le nom d'utilisateur {0} n'a pas été trouvé +DigestProcessingFilter.incorrectResponse = Réponse incorrecte +JdbcDaoImpl.notFound=Le nom d'utilisateur {0} n'a pas été trouvé +JdbcDaoImpl.noAuthority=Le compte utilisateur {0} n'a pas de permissions +SwitchUserProcessingFilter.noCurrentUser = Aucun utilisateur n'est associé à la requête en cours +SwitchUserProcessingFilter.noOriginalAuthentication = L'objet Authentication original n'a pas été trouvé +SwitchUserProcessingFilter.usernameNotFound = Le nom d'utilisateur {0} n'a pas été trouvé +SwitchUserProcessingFilter.locked = Le compte utilisateur est bloqué +SwitchUserProcessingFilter.disabled = Le compte utilisateur est désactivé +SwitchUserProcessingFilter.expired = Le compte utilisateur a expiré +SwitchUserProcessingFilter.credentialsExpired = Les créances de l'utilisateur ont expiré +AbstractAccessDecisionManager.accessDenied = Accès refusé diff --git a/core/src/main/resources/org/springframework/security/messages_ko_KR.properties b/core/src/main/resources/org/springframework/security/messages_ko_KR.properties index 428b1a4d6d..4db6c91037 100644 --- a/core/src/main/resources/org/springframework/security/messages_ko_KR.properties +++ b/core/src/main/resources/org/springframework/security/messages_ko_KR.properties @@ -33,7 +33,7 @@ JdbcDaoImpl.notFound=\uc0ac\uc6a9\uc790 {0}\uc744/\ub97c \ucc3e\uc744 \uc218 \uc JdbcDaoImpl.noAuthority=\uc0ac\uc6a9\uc790 {0}\uc740/\ub294 \uad8c\ud55c\uc774 \uc5c6\uc2b5\ub2c8\ub2e4. SwitchUserProcessingFilter.noCurrentUser=\uc0ac\uc6a9\uc790\uac00 \uc874\uc7ac\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. SwitchUserProcessingFilter.noOriginalAuthentication=Authentication\uc758 \uc6d0\ubcf8\uc744 \ucc3e\uc744 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. -SwitchUserProcessingFilter.usernameNotFound=\uc0ac\uc6a9\uc790\uba85(username) {0}\uc744/\ub97c \ucc3e\uc744 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. +SwitchUserProcessingFilter.usernameNotFound=\uc0ac\uc6a9\uc790\uba85(username) {0}\uc744/\ub97c \ucc3e\uc744 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. SwitchUserProcessingFilter.locked=\uc0ac\uc6a9\uc790 \uacc4\uc815\uc774 \uc7a0\uaca8 \uc788\uc2b5\ub2c8\ub2e4. SwitchUserProcessingFilter.disabled=\uc0ac\uc6a9\uc790 \uacc4\uc815\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. SwitchUserProcessingFilter.expired=\uc0ac\uc6a9\uc790 \uacc4\uc815\uc758 \uc720\ud6a8 \uae30\uac04\uc774 \ub9cc\ub8cc \ub418\uc5c8\uc2b5\ub2c8\ub2e4. diff --git a/core/src/main/resources/org/springframework/security/messages_uk_UA.properties b/core/src/main/resources/org/springframework/security/messages_uk_UA.properties index 3f471bd20d..a88a7aba6f 100644 --- a/core/src/main/resources/org/springframework/security/messages_uk_UA.properties +++ b/core/src/main/resources/org/springframework/security/messages_uk_UA.properties @@ -1,53 +1,53 @@ -AuthByAdapterProvider.incorrectKey=\u0414\u0430\u043D\u0430 \u0456\u043C\u043F\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u0446\u0456\u044F AuthByAdapter \u043D\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043E\u0447\u0456\u043A\u0443\u0432\u0430\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 -BasicAclEntryAfterInvocationProvider.noPermission=\u0410\u0443\u0442\u0435\u043D\u0442\u0438\u0444\u0456\u043A\u0430\u0446\u0456\u044F {0} \u043D\u0435 \u043C\u0430\u0454 \u0436\u043E\u0434\u043D\u043E\u0433\u043E \u0434\u043E\u0437\u0432\u043E\u043B\u0443 \u0434\u043B\u044F \u0434\u043E\u0441\u0442\u0443\u043F\u0443 \u0434\u043E \u043E\u0431'\u0454\u043A\u0442\u0443 \u0434\u043E\u043C\u0435\u043D\u0443 {1} -BasicAclEntryAfterInvocationProvider.insufficientPermission=\u0410\u0443\u0442\u0435\u043D\u0442\u0438\u0444\u0456\u043A\u0430\u0446\u0456\u044F {0} \u043C\u0430\u0454 ACL \u0434\u043E\u0437\u0432\u043E\u043B\u0438, \u0430\u043B\u0435 \u043D\u0435 \u043C\u0430\u0454 \u043D\u0435\u043E\u0431\u0445\u0456\u0434\u043D\u043E\u0433\u043E \u0434\u043E\u0437\u0432\u043E\u043B\u0443 \u0434\u043B\u044F \u0434\u043E\u0441\u0442\u0443\u043F\u0443 \u0434\u043E \u043E\u0431'\u0454\u043A\u0442\u0443 \u0434\u043E\u043C\u0435\u043D\u0443 {1} -ConcurrentSessionControllerImpl.exceededAllowed=\u041C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u0430 \u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C \u0441\u0435\u0441\u0456\u0439 ({0}) \u0434\u043B\u044F \u0446\u044C\u043E\u0433\u043E \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u043D\u0430 -ProviderManager.providerNotFound=AuthenticationProvider \u0434\u043B\u044F {0} \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u0438\u0439 -AnonymousAuthenticationProvider.incorrectKey=\u0414\u0430\u043D\u0438\u0439 AnonymousAuthenticationToken \u043D\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043E\u0447\u0456\u043A\u0443\u0432\u0430\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 -CasAuthenticationProvider.incorrectKey=\u0414\u0430\u043D\u0438\u0439 CasAuthenticationToken \u043D\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043E\u0447\u0456\u043A\u0443\u0432\u0430\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 -CasAuthenticationProvider.noServiceTicket=\u041D\u0435 \u043C\u043E\u0436\u043B\u0438\u0432\u043E \u043D\u0430\u0434\u0430\u0442\u0438 \u0431\u0456\u043B\u0435\u0442 \u0441\u0435\u0440\u0432\u0456\u0441\u0443 CAS \u0434\u043B\u044F \u0432\u0430\u043B\u0456\u0434\u0430\u0446\u0456\u0457 -NamedCasProxyDecider.untrusted=\u041D\u0430\u0439\u0431\u043B\u0438\u0436\u0447\u0438\u0439 \u043F\u0440\u043E\u043A\u0441\u0456-\u0441\u0435\u0440\u0432\u0435\u0440 {0} \u0454 \u043D\u0435\u043D\u0430\u0434\u0456\u0439\u043D\u0438\u043C -RejectProxyTickets.reject=\u0411\u0456\u043B\u0435\u0442\u0438 \u043F\u0440\u043E\u043A\u0441\u0456-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432\u0456\u0434\u0445\u0438\u043B\u0435\u043D\u0456 -AbstractSecurityInterceptor.authenticationNotFound=\u041E\u0431'\u0454\u043A\u0442 Authentication \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u0438\u0439 \u0432 SecurityContext -AbstractUserDetailsAuthenticationProvider.onlySupports=\u0422\u0456\u043B\u044C\u043A\u0438 UsernamePasswordAuthenticationToken \u043F\u0456\u0434\u0442\u0440\u0438\u043C\u0443\u0454\u0442\u044C\u0441\u044F -AbstractUserDetailsAuthenticationProvider.locked=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0431\u043B\u043E\u043A\u043E\u0432\u0430\u043D\u0438\u0439 -AbstractUserDetailsAuthenticationProvider.disabled=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0431\u043E\u0440\u043E\u043D\u0435\u043D\u0438\u0439 -AbstractUserDetailsAuthenticationProvider.expired=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u0432 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 -AbstractUserDetailsAuthenticationProvider.credentialsExpired=\u041F\u043E\u0432\u043D\u043E\u0432\u0430\u0436\u0435\u043D\u043D\u044F \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u043B\u0438 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 -AbstractUserDetailsAuthenticationProvider.badCredentials=\u0414\u0430\u043D\u0456 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0456 -X509AuthenticationProvider.certificateNull=\u0421\u0435\u0440\u0442\u0438\u0444\u0456\u043A\u0430\u0442 \u043F\u043E\u0440\u043E\u0436\u043D\u0456\u0439 -DaoX509AuthoritiesPopulator.noMatching=\u041D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u043D\u043E\u0433\u043E \u0448\u0430\u0431\u043B\u043E\u043D\u0443 \u0432 subjectDN: {0} -RememberMeAuthenticationProvider.incorrectKey=\u0414\u0430\u043D\u0438\u0439 RememberMeAuthenticationToken \u043D\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043E\u0447\u0456\u043A\u0443\u0432\u0430\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 -RunAsImplAuthenticationProvider.incorrectKey=\u0414\u0430\u043D\u0438\u0439 RunAsUserToken \u043D\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043E\u0447\u0456\u043A\u0443\u0432\u0430\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 -DigestProcessingFilter.missingMandatory=\u0412\u0456\u0434\u0441\u0443\u0442\u043D\u0454 \u043E\u0431\u043E\u0432'\u044F\u0437\u043A\u043E\u0432\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0434\u0430\u0439\u0434\u0436\u0435\u0441\u0442\u0430; \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u0438\u0439 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A {0} -DigestProcessingFilter.missingAuth=\u0412\u0456\u0434\u0441\u0443\u0442\u043D\u0454 \u043E\u0431\u043E\u0432'\u044F\u0437\u043A\u043E\u0432\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0434\u0430\u0439\u0434\u0436\u0435\u0441\u0442\u0430 \u0434\u043B\u044F 'auth' QOP; \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u0438\u0439 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A {0} -DigestProcessingFilter.incorrectRealm=\u041D\u0430\u0437\u0432\u0430 \u0434\u043E\u043C\u0435\u043D\u0443 {0} \u0443 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0456 \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u043D\u0430\u0437\u0432\u0456 \u0434\u043E\u043C\u0435\u043D\u0443 {1} \u0432 \u0441\u0438\u0441\u0442\u0435\u043C\u0456 -DigestProcessingFilter.nonceExpired=\u041A\u043E\u0434 (nonce) \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u0432 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 -DigestProcessingFilter.nonceEncoding=\u041A\u043E\u0434 (nonce) \u043D\u0435 \u0437\u0430\u0448\u0438\u0444\u0440\u043E\u0432\u0430\u043D\u0438\u0439 \u0432 Base64; \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u0438\u0439 \u043A\u043E\u0434 {0} -DigestProcessingFilter.nonceNotTwoTokens=\u041A\u043E\u0434 (nonce) \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 \u0434\u0432\u0430 \u0441\u0438\u043C\u0432\u043E\u043B\u0438 (tokens), \u0430\u043B\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C {0} -DigestProcessingFilter.nonceNotNumeric=\u041F\u0435\u0440\u0448\u0438\u0439 \u0441\u0438\u043C\u0432\u043E\u043B (token) \u043A\u043E\u0434 \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 \u0446\u0438\u0444\u0440\u043E\u0432\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F, \u0430 \u043C\u0456\u0441\u0442\u0438\u0442\u044C: {0} -DigestProcessingFilter.nonceCompromised=\u041A\u043E\u0434 (nonce) \u0441\u043A\u043E\u043C\u043F\u0440\u043E\u043C\u0435\u0442\u043E\u0432\u0430\u043D\u0438\u0439 {0} -DigestProcessingFilter.usernameNotFound=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 {0} \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u0438\u0439 -DigestProcessingFilter.incorrectResponse=\u041D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0430 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u044C -JdbcDaoImpl.notFound=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 {0} \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u0438\u0439 -JdbcDaoImpl.noAuthority=\u041A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447 {0} \u043D\u0435 \u043C\u0430\u0454 \u043F\u043E\u0432\u043D\u043E\u0432\u0430\u0436\u0435\u043D\u044C (GrantedAuthority) -SwitchUserProcessingFilter.noCurrentUser=\u041D\u0435\u043C\u0430\u0454 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430, \u043F\u043E\u0432'\u044F\u0437\u0430\u043D\u043E\u0433\u043E \u0456\u0437 \u0434\u0430\u043D\u0438\u043C \u0437\u0430\u043F\u0438\u0442\u043E\u043C -SwitchUserProcessingFilter.noOriginalAuthentication=\u041D\u0435 \u043C\u043E\u0436\u043B\u0438\u0432\u043E \u0437\u043D\u0430\u0439\u0442\u0438 \u043E\u0440\u0438\u0433\u0456\u043D\u0430\u043B\u044C\u043D\u0438\u0439 \u043E\u0431'\u0454\u043A\u0442 Authentication -SwitchUserProcessingFilter.usernameNotFound=\u0406\u043C'\u044F \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 {0} \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u0435 -SwitchUserProcessingFilter.locked=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0431\u043B\u043E\u043A\u043E\u0432\u0430\u043D\u0438\u0439 -SwitchUserProcessingFilter.disabled=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0431\u043E\u0440\u043E\u043D\u0435\u043D\u0438\u0439 -SwitchUserProcessingFilter.expired=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u0432 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 -SwitchUserProcessingFilter.credentialsExpired=\u041F\u043E\u0432\u043D\u043E\u0432\u0430\u0436\u0435\u043D\u043D\u044F \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u043B\u0438 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 -AbstractAccessDecisionManager.accessDenied=\u0414\u043E\u0441\u0442\u0443\u043F \u0437\u0430\u0431\u043E\u0440\u043E\u043D\u0435\u043D\u0438\u0439 -LdapAuthenticationProvider.emptyUsername=\u041F\u043E\u0440\u043E\u0436\u043D\u0454 \u0456\u043C'\u044F \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0454 \u0437\u0430\u0431\u043E\u0440\u043E\u043D\u0435\u043D\u0438\u043C -LdapAuthenticationProvider.emptyPassword=\u0414\u0430\u043D\u0456 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0456 -DefaultIntitalDirContextFactory.communicationFailure=\u041D\u0435\u043C\u043E\u0436\u043B\u0438\u0432\u043E \u0437'\u0454\u0434\u043D\u0430\u0442\u0438\u0441\u044F \u0437 LDAP \u0441\u0435\u0440\u0432\u0435\u0440\u043E\u043C -DefaultIntitalDirContextFactory.badCredentials=\u0414\u0430\u043D\u0456 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0456 -DefaultIntitalDirContextFactory.unexpectedException=\u041D\u0435\u043C\u043E\u0436\u043B\u0438\u0432\u043E \u043E\u0442\u0440\u0438\u043C\u0430\u0442\u0438 InitialDirContext \u0447\u0435\u0440\u0435\u0437 \u0432\u0438\u043D\u0438\u043A\u043D\u0435\u043D\u043D\u044F \u043D\u0435\u043E\u0447\u0456\u043A\u0443\u0432\u0430\u043D\u043E\u0457 \u043F\u043E\u043C\u0438\u043B\u043A\u0438 -PasswordComparisonAuthenticator.badCredentials=\u0414\u0430\u043D\u0456 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0456 -BindAuthenticator.badCredentials=\u0414\u0430\u043D\u0456 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0456 -BindAuthenticator.failedToLoadAttributes=\u0414\u0430\u043D\u0456 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0456 -UserDetailsService.locked=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0431\u043B\u043E\u043A\u043E\u0432\u0430\u043D\u0438\u0439 -UserDetailsService.disabled=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0431\u043E\u0440\u043E\u043D\u0435\u043D\u0438\u0439 -UserDetailsService.expired=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u0432 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 -UserDetailsService.credentialsExpired=\u041F\u043E\u0432\u043D\u043E\u0432\u0430\u0436\u0435\u043D\u043D\u044F \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u043B\u0438 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 +AuthByAdapterProvider.incorrectKey=\u0414\u0430\u043D\u0430 \u0456\u043C\u043F\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u0446\u0456\u044F AuthByAdapter \u043D\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043E\u0447\u0456\u043A\u0443\u0432\u0430\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 +BasicAclEntryAfterInvocationProvider.noPermission=\u0410\u0443\u0442\u0435\u043D\u0442\u0438\u0444\u0456\u043A\u0430\u0446\u0456\u044F {0} \u043D\u0435 \u043C\u0430\u0454 \u0436\u043E\u0434\u043D\u043E\u0433\u043E \u0434\u043E\u0437\u0432\u043E\u043B\u0443 \u0434\u043B\u044F \u0434\u043E\u0441\u0442\u0443\u043F\u0443 \u0434\u043E \u043E\u0431'\u0454\u043A\u0442\u0443 \u0434\u043E\u043C\u0435\u043D\u0443 {1} +BasicAclEntryAfterInvocationProvider.insufficientPermission=\u0410\u0443\u0442\u0435\u043D\u0442\u0438\u0444\u0456\u043A\u0430\u0446\u0456\u044F {0} \u043C\u0430\u0454 ACL \u0434\u043E\u0437\u0432\u043E\u043B\u0438, \u0430\u043B\u0435 \u043D\u0435 \u043C\u0430\u0454 \u043D\u0435\u043E\u0431\u0445\u0456\u0434\u043D\u043E\u0433\u043E \u0434\u043E\u0437\u0432\u043E\u043B\u0443 \u0434\u043B\u044F \u0434\u043E\u0441\u0442\u0443\u043F\u0443 \u0434\u043E \u043E\u0431'\u0454\u043A\u0442\u0443 \u0434\u043E\u043C\u0435\u043D\u0443 {1} +ConcurrentSessionControllerImpl.exceededAllowed=\u041C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u0430 \u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C \u0441\u0435\u0441\u0456\u0439 ({0}) \u0434\u043B\u044F \u0446\u044C\u043E\u0433\u043E \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u043D\u0430 +ProviderManager.providerNotFound=AuthenticationProvider \u0434\u043B\u044F {0} \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u0438\u0439 +AnonymousAuthenticationProvider.incorrectKey=\u0414\u0430\u043D\u0438\u0439 AnonymousAuthenticationToken \u043D\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043E\u0447\u0456\u043A\u0443\u0432\u0430\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 +CasAuthenticationProvider.incorrectKey=\u0414\u0430\u043D\u0438\u0439 CasAuthenticationToken \u043D\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043E\u0447\u0456\u043A\u0443\u0432\u0430\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 +CasAuthenticationProvider.noServiceTicket=\u041D\u0435 \u043C\u043E\u0436\u043B\u0438\u0432\u043E \u043D\u0430\u0434\u0430\u0442\u0438 \u0431\u0456\u043B\u0435\u0442 \u0441\u0435\u0440\u0432\u0456\u0441\u0443 CAS \u0434\u043B\u044F \u0432\u0430\u043B\u0456\u0434\u0430\u0446\u0456\u0457 +NamedCasProxyDecider.untrusted=\u041D\u0430\u0439\u0431\u043B\u0438\u0436\u0447\u0438\u0439 \u043F\u0440\u043E\u043A\u0441\u0456-\u0441\u0435\u0440\u0432\u0435\u0440 {0} \u0454 \u043D\u0435\u043D\u0430\u0434\u0456\u0439\u043D\u0438\u043C +RejectProxyTickets.reject=\u0411\u0456\u043B\u0435\u0442\u0438 \u043F\u0440\u043E\u043A\u0441\u0456-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432\u0456\u0434\u0445\u0438\u043B\u0435\u043D\u0456 +AbstractSecurityInterceptor.authenticationNotFound=\u041E\u0431'\u0454\u043A\u0442 Authentication \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u0438\u0439 \u0432 SecurityContext +AbstractUserDetailsAuthenticationProvider.onlySupports=\u0422\u0456\u043B\u044C\u043A\u0438 UsernamePasswordAuthenticationToken \u043F\u0456\u0434\u0442\u0440\u0438\u043C\u0443\u0454\u0442\u044C\u0441\u044F +AbstractUserDetailsAuthenticationProvider.locked=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0431\u043B\u043E\u043A\u043E\u0432\u0430\u043D\u0438\u0439 +AbstractUserDetailsAuthenticationProvider.disabled=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0431\u043E\u0440\u043E\u043D\u0435\u043D\u0438\u0439 +AbstractUserDetailsAuthenticationProvider.expired=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u0432 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 +AbstractUserDetailsAuthenticationProvider.credentialsExpired=\u041F\u043E\u0432\u043D\u043E\u0432\u0430\u0436\u0435\u043D\u043D\u044F \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u043B\u0438 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 +AbstractUserDetailsAuthenticationProvider.badCredentials=\u0414\u0430\u043D\u0456 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0456 +X509AuthenticationProvider.certificateNull=\u0421\u0435\u0440\u0442\u0438\u0444\u0456\u043A\u0430\u0442 \u043F\u043E\u0440\u043E\u0436\u043D\u0456\u0439 +DaoX509AuthoritiesPopulator.noMatching=\u041D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u043D\u043E\u0433\u043E \u0448\u0430\u0431\u043B\u043E\u043D\u0443 \u0432 subjectDN: {0} +RememberMeAuthenticationProvider.incorrectKey=\u0414\u0430\u043D\u0438\u0439 RememberMeAuthenticationToken \u043D\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043E\u0447\u0456\u043A\u0443\u0432\u0430\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 +RunAsImplAuthenticationProvider.incorrectKey=\u0414\u0430\u043D\u0438\u0439 RunAsUserToken \u043D\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C \u043E\u0447\u0456\u043A\u0443\u0432\u0430\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 +DigestProcessingFilter.missingMandatory=\u0412\u0456\u0434\u0441\u0443\u0442\u043D\u0454 \u043E\u0431\u043E\u0432'\u044F\u0437\u043A\u043E\u0432\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0434\u0430\u0439\u0434\u0436\u0435\u0441\u0442\u0430; \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u0438\u0439 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A {0} +DigestProcessingFilter.missingAuth=\u0412\u0456\u0434\u0441\u0443\u0442\u043D\u0454 \u043E\u0431\u043E\u0432'\u044F\u0437\u043A\u043E\u0432\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0434\u0430\u0439\u0434\u0436\u0435\u0441\u0442\u0430 \u0434\u043B\u044F 'auth' QOP; \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u0438\u0439 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A {0} +DigestProcessingFilter.incorrectRealm=\u041D\u0430\u0437\u0432\u0430 \u0434\u043E\u043C\u0435\u043D\u0443 {0} \u0443 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0456 \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454 \u043D\u0430\u0437\u0432\u0456 \u0434\u043E\u043C\u0435\u043D\u0443 {1} \u0432 \u0441\u0438\u0441\u0442\u0435\u043C\u0456 +DigestProcessingFilter.nonceExpired=\u041A\u043E\u0434 (nonce) \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u0432 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 +DigestProcessingFilter.nonceEncoding=\u041A\u043E\u0434 (nonce) \u043D\u0435 \u0437\u0430\u0448\u0438\u0444\u0440\u043E\u0432\u0430\u043D\u0438\u0439 \u0432 Base64; \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u0438\u0439 \u043A\u043E\u0434 {0} +DigestProcessingFilter.nonceNotTwoTokens=\u041A\u043E\u0434 (nonce) \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 \u0434\u0432\u0430 \u0441\u0438\u043C\u0432\u043E\u043B\u0438 (tokens), \u0430\u043B\u0435 \u043C\u0456\u0441\u0442\u0438\u0442\u044C {0} +DigestProcessingFilter.nonceNotNumeric=\u041F\u0435\u0440\u0448\u0438\u0439 \u0441\u0438\u043C\u0432\u043E\u043B (token) \u043A\u043E\u0434 \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 \u0446\u0438\u0444\u0440\u043E\u0432\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F, \u0430 \u043C\u0456\u0441\u0442\u0438\u0442\u044C: {0} +DigestProcessingFilter.nonceCompromised=\u041A\u043E\u0434 (nonce) \u0441\u043A\u043E\u043C\u043F\u0440\u043E\u043C\u0435\u0442\u043E\u0432\u0430\u043D\u0438\u0439 {0} +DigestProcessingFilter.usernameNotFound=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 {0} \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u0438\u0439 +DigestProcessingFilter.incorrectResponse=\u041D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0430 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u044C +JdbcDaoImpl.notFound=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 {0} \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u0438\u0439 +JdbcDaoImpl.noAuthority=\u041A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447 {0} \u043D\u0435 \u043C\u0430\u0454 \u043F\u043E\u0432\u043D\u043E\u0432\u0430\u0436\u0435\u043D\u044C (GrantedAuthority) +SwitchUserProcessingFilter.noCurrentUser=\u041D\u0435\u043C\u0430\u0454 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430, \u043F\u043E\u0432'\u044F\u0437\u0430\u043D\u043E\u0433\u043E \u0456\u0437 \u0434\u0430\u043D\u0438\u043C \u0437\u0430\u043F\u0438\u0442\u043E\u043C +SwitchUserProcessingFilter.noOriginalAuthentication=\u041D\u0435 \u043C\u043E\u0436\u043B\u0438\u0432\u043E \u0437\u043D\u0430\u0439\u0442\u0438 \u043E\u0440\u0438\u0433\u0456\u043D\u0430\u043B\u044C\u043D\u0438\u0439 \u043E\u0431'\u0454\u043A\u0442 Authentication +SwitchUserProcessingFilter.usernameNotFound=\u0406\u043C'\u044F \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 {0} \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u0435 +SwitchUserProcessingFilter.locked=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0431\u043B\u043E\u043A\u043E\u0432\u0430\u043D\u0438\u0439 +SwitchUserProcessingFilter.disabled=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0431\u043E\u0440\u043E\u043D\u0435\u043D\u0438\u0439 +SwitchUserProcessingFilter.expired=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u0432 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 +SwitchUserProcessingFilter.credentialsExpired=\u041F\u043E\u0432\u043D\u043E\u0432\u0430\u0436\u0435\u043D\u043D\u044F \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u043B\u0438 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 +AbstractAccessDecisionManager.accessDenied=\u0414\u043E\u0441\u0442\u0443\u043F \u0437\u0430\u0431\u043E\u0440\u043E\u043D\u0435\u043D\u0438\u0439 +LdapAuthenticationProvider.emptyUsername=\u041F\u043E\u0440\u043E\u0436\u043D\u0454 \u0456\u043C'\u044F \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0454 \u0437\u0430\u0431\u043E\u0440\u043E\u043D\u0435\u043D\u0438\u043C +LdapAuthenticationProvider.emptyPassword=\u0414\u0430\u043D\u0456 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0456 +DefaultIntitalDirContextFactory.communicationFailure=\u041D\u0435\u043C\u043E\u0436\u043B\u0438\u0432\u043E \u0437'\u0454\u0434\u043D\u0430\u0442\u0438\u0441\u044F \u0437 LDAP \u0441\u0435\u0440\u0432\u0435\u0440\u043E\u043C +DefaultIntitalDirContextFactory.badCredentials=\u0414\u0430\u043D\u0456 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0456 +DefaultIntitalDirContextFactory.unexpectedException=\u041D\u0435\u043C\u043E\u0436\u043B\u0438\u0432\u043E \u043E\u0442\u0440\u0438\u043C\u0430\u0442\u0438 InitialDirContext \u0447\u0435\u0440\u0435\u0437 \u0432\u0438\u043D\u0438\u043A\u043D\u0435\u043D\u043D\u044F \u043D\u0435\u043E\u0447\u0456\u043A\u0443\u0432\u0430\u043D\u043E\u0457 \u043F\u043E\u043C\u0438\u043B\u043A\u0438 +PasswordComparisonAuthenticator.badCredentials=\u0414\u0430\u043D\u0456 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0456 +BindAuthenticator.badCredentials=\u0414\u0430\u043D\u0456 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0456 +BindAuthenticator.failedToLoadAttributes=\u0414\u0430\u043D\u0456 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043D\u0435\u043A\u043E\u0440\u0435\u043A\u0442\u043D\u0456 +UserDetailsService.locked=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0431\u043B\u043E\u043A\u043E\u0432\u0430\u043D\u0438\u0439 +UserDetailsService.disabled=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0437\u0430\u0431\u043E\u0440\u043E\u043D\u0435\u043D\u0438\u0439 +UserDetailsService.expired=\u041E\u0431\u043B\u0456\u043A\u043E\u0432\u0438\u0439 \u0437\u0430\u043F\u0438\u0441 \u043A\u043E\u0440\u0443\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u0432 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 +UserDetailsService.credentialsExpired=\u041F\u043E\u0432\u043D\u043E\u0432\u0430\u0436\u0435\u043D\u043D\u044F \u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u0432\u0438\u0447\u0435\u0440\u043F\u0430\u043B\u0438 \u0442\u0435\u0440\u043C\u0456\u043D \u0434\u0456\u0457 diff --git a/core/src/main/resources/org/springframework/security/messages_zh_CN.properties b/core/src/main/resources/org/springframework/security/messages_zh_CN.properties index 7345527901..9579dc6e74 100644 --- a/core/src/main/resources/org/springframework/security/messages_zh_CN.properties +++ b/core/src/main/resources/org/springframework/security/messages_zh_CN.properties @@ -1,54 +1,54 @@ -AuthByAdapterProvider.incorrectKey=\u5c55\u793a\u7684AuthByAdapter\u5b9e\u73b0\u4e0d\u542b\u6709\u9884\u671f\u7684key -BasicAclEntryAfterInvocationProvider.noPermission=\u7ed9\u5b9a\u7684Authentication\u5bf9\u8c61({0})\u6839\u672c\u65e0\u6743\u64cd\u63a7\u9886\u57df\u5bf9\u8c61({1}) -BasicAclEntryAfterInvocationProvider.insufficientPermission=Authentication\u5bf9\u8c61({0})\u786e\u5b9e\u542b\u6709ACL\u6743\u9650\uff0c\u4f46\u5e76\u4e0d\u662f\u76ee\u6807\u9886\u57df\u5bf9\u8c61\u6240\u8981\u6c42\u7684({1}) -ConcurrentSessionControllerImpl.exceededAllowed=\u5df2\u7ecf\u8d85\u8fc7\u4e86\u5f53\u524d\u4e3b\u4f53({0})\u88ab\u5141\u8bb8\u7684\u6700\u5927\u4f1a\u8bdd\u6570\u91cf -ProviderManager.providerNotFound=\u672a\u67e5\u627e\u5230\u9488\u5bf9{0}\u7684AuthenticationProvider -AnonymousAuthenticationProvider.incorrectKey=\u5c55\u793a\u7684AnonymousAuthenticationToken\u4e0d\u542b\u6709\u9884\u671f\u7684key -CasAuthenticationProvider.incorrectKey=\u5c55\u793a\u7684CasAuthenticationToken\u4e0d\u542b\u6709\u9884\u671f\u7684key -CasAuthenticationProvider.noServiceTicket=\u672a\u80fd\u591f\u6b63\u786e\u63d0\u4f9b\u5f85\u9a8c\u8bc1\u7684CAS\u670d\u52a1\u7968\u6839 -NamedCasProxyDecider.untrusted=\u4ee3\u7406({0})\u4e0d\u53d7\u4fe1\u4efb -RejectProxyTickets.reject=Proxy\u7968\u6839\u88ab\u62d2\u7edd -AbstractSecurityInterceptor.authenticationNotFound=\u672a\u5728SecurityContext\u4e2d\u67e5\u627e\u5230\u8ba4\u8bc1\u5bf9\u8c61 -AbstractUserDetailsAuthenticationProvider.onlySupports=\u4ec5\u4ec5\u652f\u6301UsernamePasswordAuthenticationToken -AbstractUserDetailsAuthenticationProvider.locked=\u7528\u6237\u5e10\u53f7\u5df2\u88ab\u9501\u5b9a -AbstractUserDetailsAuthenticationProvider.disabled=\u7528\u6237\u5df2\u5931\u6548 -AbstractUserDetailsAuthenticationProvider.expired=\u7528\u6237\u5e10\u53f7\u5df2\u8fc7\u671f -AbstractUserDetailsAuthenticationProvider.credentialsExpired=\u7528\u6237\u51ed\u8bc1\u5df2\u8fc7\u671f -AbstractUserDetailsAuthenticationProvider.badCredentials=\u574f\u7684\u51ed\u8bc1 -X509AuthenticationProvider.certificateNull=\u672a\u63d0\u4f9b\u8bc1\u4e66 -DaoX509AuthoritiesPopulator.noMatching=\u672a\u5728subjectDN: {0}\u4e2d\u627e\u5230\u5339\u914d\u7684\u6a21\u5f0f -RememberMeAuthenticationProvider.incorrectKey=\u5c55\u793aRememberMeAuthenticationToken\u4e0d\u542b\u6709\u9884\u671f\u7684key -RunAsImplAuthenticationProvider.incorrectKey=\u5c55\u793a\u7684RunAsUserToken\u4e0d\u542b\u6709\u9884\u671f\u7684key -DigestProcessingFilter.missingMandatory=\u9057\u6f0f\u4e86\u5fc5\u987b\u7ed9\u5b9a\u7684\u6458\u8981\u53d6\u503c; \u63a5\u6536\u5230\u7684\u5934\u4fe1\u606f\u4e3a{0} -DigestProcessingFilter.missingAuth=\u9057\u6f0f\u4e86\u9488\u5bf9'auth' QOP\u7684\u3001\u5fc5\u987b\u7ed9\u5b9a\u7684\u6458\u8981\u53d6\u503c; \u63a5\u6536\u5230\u7684\u5934\u4fe1\u606f\u4e3a{0} -DigestProcessingFilter.incorrectRealm=\u54cd\u5e94\u7ed3\u679c\u4e2d\u7684Realm\u540d\u5b57({0})\u540c\u7cfb\u7edf\u6307\u5b9a\u7684Realm\u540d\u5b57({1})\u4e0d\u543b\u5408 -DigestProcessingFilter.nonceExpired=Nonce\u5df2\u7ecf\u8fc7\u671f/\u8d85\u65f6 -DigestProcessingFilter.nonceEncoding=Nonce\u672a\u7ecf\u8fc7Base64\u7f16\u7801; \u76f8\u5e94\u7684nonce\u53d6\u503c\u4e3a {0} -DigestProcessingFilter.nonceNotTwoTokens=Nonce\u5e94\u8be5\u7531\u4e24\u90e8\u5206\u53d6\u503c\u6784\u6210\uff0c\u4f46\u7ed3\u679c\u5374\u662f{0} -DigestProcessingFilter.nonceNotNumeric=Nonce\u4ee4\u724c\u7684\u7b2c1\u90e8\u5206\u5e94\u8be5\u662f\u6570\u5b57\uff0c\u4f46\u7ed3\u679c\u5374\u662f{0} -DigestProcessingFilter.nonceCompromised=Nonce\u4ee4\u724c\u5df2\u7ecf\u5b58\u5728\u95ee\u9898\u4e86\uff0c{0} -DigestProcessingFilter.usernameNotFound=\u7528\u6237\u540d{0}\u672a\u627e\u5230 -DigestProcessingFilter.incorrectResponse=\u9519\u8bef\u7684\u54cd\u5e94\u7ed3\u679c -JdbcDaoImpl.notFound=\u672a\u627e\u5230\u7528\u6237{0} -JdbcDaoImpl.noAuthority=\u6ca1\u6709\u4e3a\u7528\u6237{0}\u6307\u5b9a\u89d2\u8272 -SwitchUserProcessingFilter.noCurrentUser=\u4e0d\u5b58\u5728\u5f53\u524d\u7528\u6237 -SwitchUserProcessingFilter.noOriginalAuthentication=\u4e0d\u80fd\u591f\u67e5\u627e\u5230\u539f\u5148\u7684\u5df2\u8ba4\u8bc1\u5bf9\u8c61 -SwitchUserProcessingFilter.usernameNotFound=\u7528\u6237\u540d{0}\u672a\u627e\u5230 -SwitchUserProcessingFilter.locked=\u7528\u6237\u5e10\u53f7\u5df2\u88ab\u9501\u5b9a -SwitchUserProcessingFilter.disabled=\u7528\u6237\u5df2\u5931\u6548 -SwitchUserProcessingFilter.expired=\u7528\u6237\u5e10\u53f7\u5df2\u8fc7\u671f -SwitchUserProcessingFilter.credentialsExpired=\u7528\u6237\u51ed\u8bc1\u5df2\u8fc7\u671f -AbstractAccessDecisionManager.accessDenied=\u4e0d\u5141\u8bb8\u8bbf\u95ee -LdapAuthenticationProvider.emptyUsername=\u7528\u6237\u540d\u4e0d\u5141\u8bb8\u4e3a\u7a7a -LdapAuthenticationProvider.emptyPassword=\u574f\u7684\u51ed\u8bc1 -DefaultIntitalDirContextFactory.communicationFailure=\u4e0d\u80fd\u591f\u8fde\u63a5\u5230LDAP\u670d\u52a1\u5668 -DefaultIntitalDirContextFactory.badCredentials=\u574f\u7684\u51ed\u8bc1 -DefaultIntitalDirContextFactory.unexpectedException=\u7531\u4e8e\u672a\u9884\u671f\u5f02\u5e38\u800c\u4e0d\u80fd\u591f\u83b7\u5f97InitialDirContext -PasswordComparisonAuthenticator.badCredentials=\u574f\u7684\u51ed\u8bc1 -BindAuthenticator.badCredentials=\u574f\u7684\u51ed\u8bc1 -BindAuthenticator.failedToLoadAttributes=\u574f\u7684\u51ed\u8bc1 -UserDetailsService.locked=\u7528\u6237\u5e10\u53f7\u5df2\u88ab\u9501\u5b9a -UserDetailsService.disabled=\u7528\u6237\u5df2\u5931\u6548 -UserDetailsService.expired=\u7528\u6237\u5e10\u53f7\u5df2\u8fc7\u671f -UserDetailsService.credentialsExpired=\u7528\u6237\u51ed\u8bc1\u5df2\u8fc7\u671f - +AuthByAdapterProvider.incorrectKey=\u5c55\u793a\u7684AuthByAdapter\u5b9e\u73b0\u4e0d\u542b\u6709\u9884\u671f\u7684key +BasicAclEntryAfterInvocationProvider.noPermission=\u7ed9\u5b9a\u7684Authentication\u5bf9\u8c61({0})\u6839\u672c\u65e0\u6743\u64cd\u63a7\u9886\u57df\u5bf9\u8c61({1}) +BasicAclEntryAfterInvocationProvider.insufficientPermission=Authentication\u5bf9\u8c61({0})\u786e\u5b9e\u542b\u6709ACL\u6743\u9650\uff0c\u4f46\u5e76\u4e0d\u662f\u76ee\u6807\u9886\u57df\u5bf9\u8c61\u6240\u8981\u6c42\u7684({1}) +ConcurrentSessionControllerImpl.exceededAllowed=\u5df2\u7ecf\u8d85\u8fc7\u4e86\u5f53\u524d\u4e3b\u4f53({0})\u88ab\u5141\u8bb8\u7684\u6700\u5927\u4f1a\u8bdd\u6570\u91cf +ProviderManager.providerNotFound=\u672a\u67e5\u627e\u5230\u9488\u5bf9{0}\u7684AuthenticationProvider +AnonymousAuthenticationProvider.incorrectKey=\u5c55\u793a\u7684AnonymousAuthenticationToken\u4e0d\u542b\u6709\u9884\u671f\u7684key +CasAuthenticationProvider.incorrectKey=\u5c55\u793a\u7684CasAuthenticationToken\u4e0d\u542b\u6709\u9884\u671f\u7684key +CasAuthenticationProvider.noServiceTicket=\u672a\u80fd\u591f\u6b63\u786e\u63d0\u4f9b\u5f85\u9a8c\u8bc1\u7684CAS\u670d\u52a1\u7968\u6839 +NamedCasProxyDecider.untrusted=\u4ee3\u7406({0})\u4e0d\u53d7\u4fe1\u4efb +RejectProxyTickets.reject=Proxy\u7968\u6839\u88ab\u62d2\u7edd +AbstractSecurityInterceptor.authenticationNotFound=\u672a\u5728SecurityContext\u4e2d\u67e5\u627e\u5230\u8ba4\u8bc1\u5bf9\u8c61 +AbstractUserDetailsAuthenticationProvider.onlySupports=\u4ec5\u4ec5\u652f\u6301UsernamePasswordAuthenticationToken +AbstractUserDetailsAuthenticationProvider.locked=\u7528\u6237\u5e10\u53f7\u5df2\u88ab\u9501\u5b9a +AbstractUserDetailsAuthenticationProvider.disabled=\u7528\u6237\u5df2\u5931\u6548 +AbstractUserDetailsAuthenticationProvider.expired=\u7528\u6237\u5e10\u53f7\u5df2\u8fc7\u671f +AbstractUserDetailsAuthenticationProvider.credentialsExpired=\u7528\u6237\u51ed\u8bc1\u5df2\u8fc7\u671f +AbstractUserDetailsAuthenticationProvider.badCredentials=\u574f\u7684\u51ed\u8bc1 +X509AuthenticationProvider.certificateNull=\u672a\u63d0\u4f9b\u8bc1\u4e66 +DaoX509AuthoritiesPopulator.noMatching=\u672a\u5728subjectDN: {0}\u4e2d\u627e\u5230\u5339\u914d\u7684\u6a21\u5f0f +RememberMeAuthenticationProvider.incorrectKey=\u5c55\u793aRememberMeAuthenticationToken\u4e0d\u542b\u6709\u9884\u671f\u7684key +RunAsImplAuthenticationProvider.incorrectKey=\u5c55\u793a\u7684RunAsUserToken\u4e0d\u542b\u6709\u9884\u671f\u7684key +DigestProcessingFilter.missingMandatory=\u9057\u6f0f\u4e86\u5fc5\u987b\u7ed9\u5b9a\u7684\u6458\u8981\u53d6\u503c; \u63a5\u6536\u5230\u7684\u5934\u4fe1\u606f\u4e3a{0} +DigestProcessingFilter.missingAuth=\u9057\u6f0f\u4e86\u9488\u5bf9'auth' QOP\u7684\u3001\u5fc5\u987b\u7ed9\u5b9a\u7684\u6458\u8981\u53d6\u503c; \u63a5\u6536\u5230\u7684\u5934\u4fe1\u606f\u4e3a{0} +DigestProcessingFilter.incorrectRealm=\u54cd\u5e94\u7ed3\u679c\u4e2d\u7684Realm\u540d\u5b57({0})\u540c\u7cfb\u7edf\u6307\u5b9a\u7684Realm\u540d\u5b57({1})\u4e0d\u543b\u5408 +DigestProcessingFilter.nonceExpired=Nonce\u5df2\u7ecf\u8fc7\u671f/\u8d85\u65f6 +DigestProcessingFilter.nonceEncoding=Nonce\u672a\u7ecf\u8fc7Base64\u7f16\u7801; \u76f8\u5e94\u7684nonce\u53d6\u503c\u4e3a {0} +DigestProcessingFilter.nonceNotTwoTokens=Nonce\u5e94\u8be5\u7531\u4e24\u90e8\u5206\u53d6\u503c\u6784\u6210\uff0c\u4f46\u7ed3\u679c\u5374\u662f{0} +DigestProcessingFilter.nonceNotNumeric=Nonce\u4ee4\u724c\u7684\u7b2c1\u90e8\u5206\u5e94\u8be5\u662f\u6570\u5b57\uff0c\u4f46\u7ed3\u679c\u5374\u662f{0} +DigestProcessingFilter.nonceCompromised=Nonce\u4ee4\u724c\u5df2\u7ecf\u5b58\u5728\u95ee\u9898\u4e86\uff0c{0} +DigestProcessingFilter.usernameNotFound=\u7528\u6237\u540d{0}\u672a\u627e\u5230 +DigestProcessingFilter.incorrectResponse=\u9519\u8bef\u7684\u54cd\u5e94\u7ed3\u679c +JdbcDaoImpl.notFound=\u672a\u627e\u5230\u7528\u6237{0} +JdbcDaoImpl.noAuthority=\u6ca1\u6709\u4e3a\u7528\u6237{0}\u6307\u5b9a\u89d2\u8272 +SwitchUserProcessingFilter.noCurrentUser=\u4e0d\u5b58\u5728\u5f53\u524d\u7528\u6237 +SwitchUserProcessingFilter.noOriginalAuthentication=\u4e0d\u80fd\u591f\u67e5\u627e\u5230\u539f\u5148\u7684\u5df2\u8ba4\u8bc1\u5bf9\u8c61 +SwitchUserProcessingFilter.usernameNotFound=\u7528\u6237\u540d{0}\u672a\u627e\u5230 +SwitchUserProcessingFilter.locked=\u7528\u6237\u5e10\u53f7\u5df2\u88ab\u9501\u5b9a +SwitchUserProcessingFilter.disabled=\u7528\u6237\u5df2\u5931\u6548 +SwitchUserProcessingFilter.expired=\u7528\u6237\u5e10\u53f7\u5df2\u8fc7\u671f +SwitchUserProcessingFilter.credentialsExpired=\u7528\u6237\u51ed\u8bc1\u5df2\u8fc7\u671f +AbstractAccessDecisionManager.accessDenied=\u4e0d\u5141\u8bb8\u8bbf\u95ee +LdapAuthenticationProvider.emptyUsername=\u7528\u6237\u540d\u4e0d\u5141\u8bb8\u4e3a\u7a7a +LdapAuthenticationProvider.emptyPassword=\u574f\u7684\u51ed\u8bc1 +DefaultIntitalDirContextFactory.communicationFailure=\u4e0d\u80fd\u591f\u8fde\u63a5\u5230LDAP\u670d\u52a1\u5668 +DefaultIntitalDirContextFactory.badCredentials=\u574f\u7684\u51ed\u8bc1 +DefaultIntitalDirContextFactory.unexpectedException=\u7531\u4e8e\u672a\u9884\u671f\u5f02\u5e38\u800c\u4e0d\u80fd\u591f\u83b7\u5f97InitialDirContext +PasswordComparisonAuthenticator.badCredentials=\u574f\u7684\u51ed\u8bc1 +BindAuthenticator.badCredentials=\u574f\u7684\u51ed\u8bc1 +BindAuthenticator.failedToLoadAttributes=\u574f\u7684\u51ed\u8bc1 +UserDetailsService.locked=\u7528\u6237\u5e10\u53f7\u5df2\u88ab\u9501\u5b9a +UserDetailsService.disabled=\u7528\u6237\u5df2\u5931\u6548 +UserDetailsService.expired=\u7528\u6237\u5e10\u53f7\u5df2\u8fc7\u671f +UserDetailsService.credentialsExpired=\u7528\u6237\u51ed\u8bc1\u5df2\u8fc7\u671f + diff --git a/core/src/test/java/org/springframework/security/ITargetObject.java b/core/src/test/java/org/springframework/security/ITargetObject.java index 0c073ec078..4e0cc06d66 100644 --- a/core/src/test/java/org/springframework/security/ITargetObject.java +++ b/core/src/test/java/org/springframework/security/ITargetObject.java @@ -19,7 +19,6 @@ package org.springframework.security; * Represents the interface of a secured object. * * @author Ben Alex - * @version $Id$ */ public interface ITargetObject { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/MockAuthenticationManager.java b/core/src/test/java/org/springframework/security/MockAuthenticationManager.java index 23f408a62c..0d5dcf3600 100644 --- a/core/src/test/java/org/springframework/security/MockAuthenticationManager.java +++ b/core/src/test/java/org/springframework/security/MockAuthenticationManager.java @@ -25,7 +25,6 @@ import org.springframework.security.core.AuthenticationException; * * @author Ben Alex * @author Wesley Hall - * @version $Id$ */ public class MockAuthenticationManager extends AbstractAuthenticationManager { //~ Instance fields ================================================================================================ diff --git a/core/src/test/java/org/springframework/security/MockJoinPoint.java b/core/src/test/java/org/springframework/security/MockJoinPoint.java index 041175cd7e..964a409a97 100644 --- a/core/src/test/java/org/springframework/security/MockJoinPoint.java +++ b/core/src/test/java/org/springframework/security/MockJoinPoint.java @@ -27,7 +27,6 @@ import java.lang.reflect.Method; * A mock AspectJ JoinPoint. * * @author Ben Alex - * @version $Id$ */ @SuppressWarnings("unchecked") public class MockJoinPoint implements JoinPoint { diff --git a/core/src/test/java/org/springframework/security/OtherTargetObject.java b/core/src/test/java/org/springframework/security/OtherTargetObject.java index 5d57ca56f7..ce9366f60f 100644 --- a/core/src/test/java/org/springframework/security/OtherTargetObject.java +++ b/core/src/test/java/org/springframework/security/OtherTargetObject.java @@ -24,7 +24,6 @@ package org.springframework.security; * its parent class or classes).

* * @author Ben Alex - * @version $Id$ */ public class OtherTargetObject extends TargetObject implements ITargetObject { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/PopulatedDatabase.java b/core/src/test/java/org/springframework/security/PopulatedDatabase.java index 19feb52c84..000c7e9b0f 100644 --- a/core/src/test/java/org/springframework/security/PopulatedDatabase.java +++ b/core/src/test/java/org/springframework/security/PopulatedDatabase.java @@ -24,7 +24,6 @@ import javax.sql.DataSource; * Singleton which provides a populated database connection for all JDBC-related unit tests. * * @author Ben Alex - * @version $Id$ */ public class PopulatedDatabase { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/test/java/org/springframework/security/TargetObject.java b/core/src/test/java/org/springframework/security/TargetObject.java index 209c21cbde..9a7f045c0f 100644 --- a/core/src/test/java/org/springframework/security/TargetObject.java +++ b/core/src/test/java/org/springframework/security/TargetObject.java @@ -23,7 +23,6 @@ import org.springframework.security.core.context.SecurityContextHolder; * Represents a secured object. * * @author Ben Alex - * @version $Id$ */ public class TargetObject implements ITargetObject { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/TestDataSource.java b/core/src/test/java/org/springframework/security/TestDataSource.java index 183ff882d8..5c322d61f7 100644 --- a/core/src/test/java/org/springframework/security/TestDataSource.java +++ b/core/src/test/java/org/springframework/security/TestDataSource.java @@ -9,14 +9,13 @@ import org.springframework.beans.factory.DisposableBean; * shuts down the database when the application context it is defined in is closed. * * @author Luke Taylor - * @version $Id$ */ public class TestDataSource extends DriverManagerDataSource implements DisposableBean { String name; public TestDataSource(String databaseName) { name = databaseName; - System.out.println("Creating database: " + name); + System.out.println("Creating database: " + name); setDriverClassName("org.hsqldb.jdbcDriver"); setUrl("jdbc:hsqldb:mem:" + databaseName); setUsername("sa"); diff --git a/core/src/test/java/org/springframework/security/access/AuthenticationCredentialsNotFoundEventTests.java b/core/src/test/java/org/springframework/security/access/AuthenticationCredentialsNotFoundEventTests.java index 4ccc61091e..8c20ce0ecf 100644 --- a/core/src/test/java/org/springframework/security/access/AuthenticationCredentialsNotFoundEventTests.java +++ b/core/src/test/java/org/springframework/security/access/AuthenticationCredentialsNotFoundEventTests.java @@ -26,7 +26,6 @@ import org.springframework.security.util.SimpleMethodInvocation; * Tests {@link AuthenticationCredentialsNotFoundEvent}. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationCredentialsNotFoundEventTests { diff --git a/core/src/test/java/org/springframework/security/access/AuthorizationFailureEventTests.java b/core/src/test/java/org/springframework/security/access/AuthorizationFailureEventTests.java index 73427ea268..7c5dc9c99b 100644 --- a/core/src/test/java/org/springframework/security/access/AuthorizationFailureEventTests.java +++ b/core/src/test/java/org/springframework/security/access/AuthorizationFailureEventTests.java @@ -27,7 +27,6 @@ import org.springframework.security.util.SimpleMethodInvocation; * Tests {@link AuthorizationFailureEvent}. * * @author Ben Alex - * @version $Id$ */ public class AuthorizationFailureEventTests { diff --git a/core/src/test/java/org/springframework/security/access/AuthorizedEventTests.java b/core/src/test/java/org/springframework/security/access/AuthorizedEventTests.java index a33ec8c14d..32152dadc5 100644 --- a/core/src/test/java/org/springframework/security/access/AuthorizedEventTests.java +++ b/core/src/test/java/org/springframework/security/access/AuthorizedEventTests.java @@ -26,7 +26,6 @@ import org.springframework.security.util.SimpleMethodInvocation; * Tests {@link AuthorizedEvent}. * * @author Ben Alex - * @version $Id$ */ public class AuthorizedEventTests { diff --git a/core/src/test/java/org/springframework/security/access/SecurityConfigTests.java b/core/src/test/java/org/springframework/security/access/SecurityConfigTests.java index fbe438c816..54218f725e 100644 --- a/core/src/test/java/org/springframework/security/access/SecurityConfigTests.java +++ b/core/src/test/java/org/springframework/security/access/SecurityConfigTests.java @@ -26,7 +26,6 @@ import org.springframework.security.access.SecurityConfig; * Tests {@link SecurityConfig}. * * @author Ben Alex - * @version $Id$ */ public class SecurityConfigTests { @@ -37,7 +36,7 @@ public class SecurityConfigTests { SecurityConfig config = new SecurityConfig("TEST"); Assert.assertEquals("TEST".hashCode(), config.hashCode()); } - + @Test(expected=IllegalArgumentException.class) public void testCannotConstructWithNullAttribute() { new SecurityConfig(null); // SEC-727 @@ -84,7 +83,7 @@ public class SecurityConfigTests { SecurityConfig config = new SecurityConfig("TEST"); Assert.assertEquals("TEST", config.toString()); } - + //~ Inner Classes ================================================================================================== private class MockConfigAttribute implements ConfigAttribute { diff --git a/core/src/test/java/org/springframework/security/access/annotation/BusinessService.java b/core/src/test/java/org/springframework/security/access/annotation/BusinessService.java index 52cc679ff1..29c000d3bb 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/BusinessService.java +++ b/core/src/test/java/org/springframework/security/access/annotation/BusinessService.java @@ -24,7 +24,6 @@ import org.springframework.security.access.annotation.Secured; import org.springframework.security.access.prepost.PreAuthorize; /** - * @version $Id$ */ @Secured({"ROLE_USER"}) @PermitAll diff --git a/core/src/test/java/org/springframework/security/access/annotation/Jsr250BusinessServiceImpl.java b/core/src/test/java/org/springframework/security/access/annotation/Jsr250BusinessServiceImpl.java index 7077359161..01b59c26c6 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/Jsr250BusinessServiceImpl.java +++ b/core/src/test/java/org/springframework/security/access/annotation/Jsr250BusinessServiceImpl.java @@ -10,7 +10,6 @@ import javax.annotation.security.PermitAll; /** * * @author Luke Taylor - * @version $Id$ */ @PermitAll public class Jsr250BusinessServiceImpl implements BusinessService { diff --git a/core/src/test/java/org/springframework/security/access/annotation/Jsr250MethodDefinitionSourceTests.java b/core/src/test/java/org/springframework/security/access/annotation/Jsr250MethodDefinitionSourceTests.java index fcd23d55d0..0621399dbb 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/Jsr250MethodDefinitionSourceTests.java +++ b/core/src/test/java/org/springframework/security/access/annotation/Jsr250MethodDefinitionSourceTests.java @@ -15,7 +15,6 @@ import org.springframework.security.access.ConfigAttribute; /** * @author Luke Taylor * @author Ben Alex - * @version $Id$ */ public class Jsr250MethodDefinitionSourceTests { Jsr250MethodSecurityMetadataSource mds = new Jsr250MethodSecurityMetadataSource(); diff --git a/core/src/test/java/org/springframework/security/access/annotation/MethodDefinitionSourceEditorTigerTests.java b/core/src/test/java/org/springframework/security/access/annotation/MethodDefinitionSourceEditorTigerTests.java index d47d456741..d278176586 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/MethodDefinitionSourceEditorTigerTests.java +++ b/core/src/test/java/org/springframework/security/access/annotation/MethodDefinitionSourceEditorTigerTests.java @@ -36,7 +36,6 @@ import org.springframework.security.access.method.MethodSecurityMetadataSourceEd * Extra tests to demonstrate generics behaviour with MapBasedMethodDefinitionSource. * * @author Ben Alex - * @version $Id$ */ @SuppressWarnings("deprecation") public class MethodDefinitionSourceEditorTigerTests { diff --git a/core/src/test/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataDefinitionSourceTests.java b/core/src/test/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataDefinitionSourceTests.java index 1048dfbb49..439de1aaa8 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataDefinitionSourceTests.java +++ b/core/src/test/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataDefinitionSourceTests.java @@ -32,7 +32,6 @@ import org.springframework.util.StringUtils; * @author Mark St.Godard * @author Joe Scalise * @author Ben Alex - * @version $Id$ */ public class SecuredAnnotationSecurityMetadataDefinitionSourceTests extends TestCase { //~ Instance fields ================================================================================================ diff --git a/core/src/test/java/org/springframework/security/access/annotation/test/Entity.java b/core/src/test/java/org/springframework/security/access/annotation/test/Entity.java index c93ea8d3b6..d547102b42 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/test/Entity.java +++ b/core/src/test/java/org/springframework/security/access/annotation/test/Entity.java @@ -22,7 +22,6 @@ import org.springframework.util.Assert; * An entity used in our generics testing. * * @author Ben Alex - * @version $Id$ */ public class Entity { //~ Instance fields ================================================================================================ diff --git a/core/src/test/java/org/springframework/security/access/annotation/test/Organisation.java b/core/src/test/java/org/springframework/security/access/annotation/test/Organisation.java index b5cbde1934..d3d6b0c46d 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/test/Organisation.java +++ b/core/src/test/java/org/springframework/security/access/annotation/test/Organisation.java @@ -19,7 +19,6 @@ package org.springframework.security.access.annotation.test; * An extended version of Entity. * * @author Ben Alex - * @version $Id$ */ public class Organisation extends Entity { //~ Instance fields ================================================================================================ diff --git a/core/src/test/java/org/springframework/security/access/annotation/test/OrganisationService.java b/core/src/test/java/org/springframework/security/access/annotation/test/OrganisationService.java index a546d40022..86ec72b6be 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/test/OrganisationService.java +++ b/core/src/test/java/org/springframework/security/access/annotation/test/OrganisationService.java @@ -18,8 +18,6 @@ package org.springframework.security.access.annotation.test; /** * DOCUMENT ME! * - * @author $author$ - * @version $Revision: 1496 $ */ public interface OrganisationService extends Service { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/access/annotation/test/Person.java b/core/src/test/java/org/springframework/security/access/annotation/test/Person.java index f605ac3807..4389ccd25a 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/test/Person.java +++ b/core/src/test/java/org/springframework/security/access/annotation/test/Person.java @@ -19,7 +19,6 @@ package org.springframework.security.access.annotation.test; * An extended version of Entity. * * @author Ben Alex - * @version $Id$ */ public class Person extends Entity { //~ Instance fields ================================================================================================ diff --git a/core/src/test/java/org/springframework/security/access/annotation/test/PersonServiceImpl.java b/core/src/test/java/org/springframework/security/access/annotation/test/PersonServiceImpl.java index 754f27df7d..65d3649d42 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/test/PersonServiceImpl.java +++ b/core/src/test/java/org/springframework/security/access/annotation/test/PersonServiceImpl.java @@ -18,8 +18,6 @@ package org.springframework.security.access.annotation.test; /** * DOCUMENT ME! * - * @author $author$ - * @version $Revision: 1496 $ */ public class PersonServiceImpl extends ServiceImpl implements PersonService { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/access/annotation/test/Service.java b/core/src/test/java/org/springframework/security/access/annotation/test/Service.java index c981a28dca..ed7a4ddb86 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/test/Service.java +++ b/core/src/test/java/org/springframework/security/access/annotation/test/Service.java @@ -22,7 +22,6 @@ import java.util.Collection; * An interface that uses Java 5 generics. * * @author Ben Alex - * @version $Id$ */ public interface Service { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/access/expression/SecurityExpressionRootTests.java b/core/src/test/java/org/springframework/security/access/expression/SecurityExpressionRootTests.java index d98189989c..3d7dc9e5af 100644 --- a/core/src/test/java/org/springframework/security/access/expression/SecurityExpressionRootTests.java +++ b/core/src/test/java/org/springframework/security/access/expression/SecurityExpressionRootTests.java @@ -13,7 +13,6 @@ import org.springframework.security.core.authority.AuthorityUtils; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class SecurityExpressionRootTests { diff --git a/core/src/test/java/org/springframework/security/access/expression/method/MethodSecurityExpressionRootTests.java b/core/src/test/java/org/springframework/security/access/expression/method/MethodSecurityExpressionRootTests.java index e6efb0b496..f1f10719c8 100644 --- a/core/src/test/java/org/springframework/security/access/expression/method/MethodSecurityExpressionRootTests.java +++ b/core/src/test/java/org/springframework/security/access/expression/method/MethodSecurityExpressionRootTests.java @@ -18,7 +18,6 @@ import org.springframework.security.core.Authentication; * Tests for {@link MethodSecurityExpressionRoot} * * @author Luke Taylor - * @version $Id$ */ public class MethodSecurityExpressionRootTests { SpelExpressionParser parser = new SpelExpressionParser(); diff --git a/core/src/test/java/org/springframework/security/access/expression/method/PrePostAnnotationSecurityMetadataSourceTests.java b/core/src/test/java/org/springframework/security/access/expression/method/PrePostAnnotationSecurityMetadataSourceTests.java index 801b46d4fd..18de1406fb 100644 --- a/core/src/test/java/org/springframework/security/access/expression/method/PrePostAnnotationSecurityMetadataSourceTests.java +++ b/core/src/test/java/org/springframework/security/access/expression/method/PrePostAnnotationSecurityMetadataSourceTests.java @@ -17,7 +17,6 @@ import org.springframework.security.access.prepost.PrePostAnnotationSecurityMeta /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class PrePostAnnotationSecurityMetadataSourceTests { diff --git a/core/src/test/java/org/springframework/security/access/hierarchicalroles/RoleHierarchyImplTests.java b/core/src/test/java/org/springframework/security/access/hierarchicalroles/RoleHierarchyImplTests.java index 060e02baeb..6f3aa90564 100755 --- a/core/src/test/java/org/springframework/security/access/hierarchicalroles/RoleHierarchyImplTests.java +++ b/core/src/test/java/org/springframework/security/access/hierarchicalroles/RoleHierarchyImplTests.java @@ -110,7 +110,7 @@ public class RoleHierarchyImplTests extends TestCase { fail("A cycle in role hierarchy was incorrectly detected!"); } } - + // SEC-863 public void testSimpleRoleHierarchyWithCustomGrantedAuthorityImplementation() { diff --git a/core/src/test/java/org/springframework/security/access/hierarchicalroles/UserDetailsServiceWrapperTests.java b/core/src/test/java/org/springframework/security/access/hierarchicalroles/UserDetailsServiceWrapperTests.java index adad24f009..4791ebc311 100755 --- a/core/src/test/java/org/springframework/security/access/hierarchicalroles/UserDetailsServiceWrapperTests.java +++ b/core/src/test/java/org/springframework/security/access/hierarchicalroles/UserDetailsServiceWrapperTests.java @@ -1,78 +1,78 @@ -package org.springframework.security.access.hierarchicalroles; - -import static org.junit.Assert.*; - -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.jmock.integration.junit4.JMock; -import org.jmock.integration.junit4.JUnit4Mockery; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.EmptyResultDataAccessException; -import org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl; -import org.springframework.security.access.hierarchicalroles.UserDetailsServiceWrapper; -import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -@RunWith(JMock.class) -@SuppressWarnings("deprecation") -public class UserDetailsServiceWrapperTests { - - private UserDetailsService wrappedUserDetailsService = null; - private UserDetailsServiceWrapper userDetailsServiceWrapper = null; - private Mockery jmockContext = new JUnit4Mockery(); - - @Before - public void setUp() throws Exception { - RoleHierarchyImpl roleHierarchy = new RoleHierarchyImpl(); - roleHierarchy.setHierarchy("ROLE_A > ROLE_B"); - final UserDetails user = new User("EXISTING_USER", "PASSWORD", true, true, true, true, - AuthorityUtils.createAuthorityList("ROLE_A")); - final UserDetailsService wrappedUserDetailsService = jmockContext.mock(UserDetailsService.class); - - jmockContext.checking( new Expectations() {{ - allowing(wrappedUserDetailsService).loadUserByUsername("EXISTING_USER"); will(returnValue(user)); - allowing(wrappedUserDetailsService).loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION"); will(throwException(new UsernameNotFoundException("USERNAME_NOT_FOUND_EXCEPTION"))); - allowing(wrappedUserDetailsService).loadUserByUsername("DATA_ACCESS_EXCEPTION"); will(throwException(new EmptyResultDataAccessException(1234))); - }}); - this.wrappedUserDetailsService = wrappedUserDetailsService; - userDetailsServiceWrapper = new UserDetailsServiceWrapper(); - userDetailsServiceWrapper.setRoleHierarchy(roleHierarchy); - userDetailsServiceWrapper.setUserDetailsService(wrappedUserDetailsService); - } - - @Test - public void testLoadUserByUsername() { - UserDetails expectedUserDetails = new User("EXISTING_USER", "PASSWORD", true, true, true, true, - AuthorityUtils.createAuthorityList("ROLE_A", "ROLE_B")); - UserDetails userDetails = userDetailsServiceWrapper.loadUserByUsername("EXISTING_USER"); - assertEquals(expectedUserDetails.getPassword(), userDetails.getPassword()); - assertEquals(expectedUserDetails.getUsername(), userDetails.getUsername()); - assertEquals(expectedUserDetails.isAccountNonExpired(), userDetails.isAccountNonExpired()); - assertEquals(expectedUserDetails.isAccountNonLocked(), userDetails.isAccountNonLocked()); - assertEquals(expectedUserDetails.isCredentialsNonExpired(), expectedUserDetails.isCredentialsNonExpired()); - assertEquals(expectedUserDetails.isEnabled(), userDetails.isEnabled()); - assertTrue(HierarchicalRolesTestHelper.containTheSameGrantedAuthorities(expectedUserDetails.getAuthorities(), userDetails.getAuthorities())); - - try { - userDetails = userDetailsServiceWrapper.loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION"); - fail("testLoadUserByUsername() - UsernameNotFoundException did not bubble up!"); - } catch (UsernameNotFoundException e) {} - - try { - userDetails = userDetailsServiceWrapper.loadUserByUsername("DATA_ACCESS_EXCEPTION"); - fail("testLoadUserByUsername() - DataAccessException did not bubble up!"); - } catch (DataAccessException e) {} - } - - @Test - public void testGetWrappedUserDetailsService() { - assertTrue(userDetailsServiceWrapper.getWrappedUserDetailsService() == wrappedUserDetailsService); - } - -} +package org.springframework.security.access.hierarchicalroles; + +import static org.junit.Assert.*; + +import org.jmock.Expectations; +import org.jmock.Mockery; +import org.jmock.integration.junit4.JMock; +import org.jmock.integration.junit4.JUnit4Mockery; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.EmptyResultDataAccessException; +import org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl; +import org.springframework.security.access.hierarchicalroles.UserDetailsServiceWrapper; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; + +@RunWith(JMock.class) +@SuppressWarnings("deprecation") +public class UserDetailsServiceWrapperTests { + + private UserDetailsService wrappedUserDetailsService = null; + private UserDetailsServiceWrapper userDetailsServiceWrapper = null; + private Mockery jmockContext = new JUnit4Mockery(); + + @Before + public void setUp() throws Exception { + RoleHierarchyImpl roleHierarchy = new RoleHierarchyImpl(); + roleHierarchy.setHierarchy("ROLE_A > ROLE_B"); + final UserDetails user = new User("EXISTING_USER", "PASSWORD", true, true, true, true, + AuthorityUtils.createAuthorityList("ROLE_A")); + final UserDetailsService wrappedUserDetailsService = jmockContext.mock(UserDetailsService.class); + + jmockContext.checking( new Expectations() {{ + allowing(wrappedUserDetailsService).loadUserByUsername("EXISTING_USER"); will(returnValue(user)); + allowing(wrappedUserDetailsService).loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION"); will(throwException(new UsernameNotFoundException("USERNAME_NOT_FOUND_EXCEPTION"))); + allowing(wrappedUserDetailsService).loadUserByUsername("DATA_ACCESS_EXCEPTION"); will(throwException(new EmptyResultDataAccessException(1234))); + }}); + this.wrappedUserDetailsService = wrappedUserDetailsService; + userDetailsServiceWrapper = new UserDetailsServiceWrapper(); + userDetailsServiceWrapper.setRoleHierarchy(roleHierarchy); + userDetailsServiceWrapper.setUserDetailsService(wrappedUserDetailsService); + } + + @Test + public void testLoadUserByUsername() { + UserDetails expectedUserDetails = new User("EXISTING_USER", "PASSWORD", true, true, true, true, + AuthorityUtils.createAuthorityList("ROLE_A", "ROLE_B")); + UserDetails userDetails = userDetailsServiceWrapper.loadUserByUsername("EXISTING_USER"); + assertEquals(expectedUserDetails.getPassword(), userDetails.getPassword()); + assertEquals(expectedUserDetails.getUsername(), userDetails.getUsername()); + assertEquals(expectedUserDetails.isAccountNonExpired(), userDetails.isAccountNonExpired()); + assertEquals(expectedUserDetails.isAccountNonLocked(), userDetails.isAccountNonLocked()); + assertEquals(expectedUserDetails.isCredentialsNonExpired(), expectedUserDetails.isCredentialsNonExpired()); + assertEquals(expectedUserDetails.isEnabled(), userDetails.isEnabled()); + assertTrue(HierarchicalRolesTestHelper.containTheSameGrantedAuthorities(expectedUserDetails.getAuthorities(), userDetails.getAuthorities())); + + try { + userDetails = userDetailsServiceWrapper.loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION"); + fail("testLoadUserByUsername() - UsernameNotFoundException did not bubble up!"); + } catch (UsernameNotFoundException e) {} + + try { + userDetails = userDetailsServiceWrapper.loadUserByUsername("DATA_ACCESS_EXCEPTION"); + fail("testLoadUserByUsername() - DataAccessException did not bubble up!"); + } catch (DataAccessException e) {} + } + + @Test + public void testGetWrappedUserDetailsService() { + assertTrue(userDetailsServiceWrapper.getWrappedUserDetailsService() == wrappedUserDetailsService); + } + +} diff --git a/core/src/test/java/org/springframework/security/access/hierarchicalroles/UserDetailsWrapperTests.java b/core/src/test/java/org/springframework/security/access/hierarchicalroles/UserDetailsWrapperTests.java index 7b7d5b0cb3..809201f363 100755 --- a/core/src/test/java/org/springframework/security/access/hierarchicalroles/UserDetailsWrapperTests.java +++ b/core/src/test/java/org/springframework/security/access/hierarchicalroles/UserDetailsWrapperTests.java @@ -1,86 +1,86 @@ -package org.springframework.security.access.hierarchicalroles; - -import java.util.List; - -import junit.framework.TestCase; - -import org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl; -import org.springframework.security.access.hierarchicalroles.UserDetailsWrapper; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; - -/** - * Tests for {@link UserDetailsWrapper}. - * - * @author Michael Mayr - */ -@SuppressWarnings("deprecation") -public class UserDetailsWrapperTests extends TestCase { - - private List authorities = null; - private UserDetails userDetails1 = null; - private UserDetails userDetails2 = null; - private UserDetailsWrapper userDetailsWrapper1 = null; - private UserDetailsWrapper userDetailsWrapper2 = null; - - public UserDetailsWrapperTests() { - } - - public UserDetailsWrapperTests(String testCaseName) { - super(testCaseName); - } - - protected void setUp() throws Exception { - RoleHierarchyImpl roleHierarchy = new RoleHierarchyImpl(); - roleHierarchy.setHierarchy("ROLE_A > ROLE_B"); - authorities = AuthorityUtils.createAuthorityList("ROLE_A"); - userDetails1 = new User("TestUser1", "TestPassword1", true, true, true, true, authorities); - userDetails2 = new User("TestUser2", "TestPassword2", false, false, false, false, authorities); - userDetailsWrapper1 = new UserDetailsWrapper(userDetails1, roleHierarchy); - userDetailsWrapper2 = new UserDetailsWrapper(userDetails2, roleHierarchy); - } - - public void testIsAccountNonExpired() { - assertEquals(userDetails1.isAccountNonExpired(), userDetailsWrapper1.isAccountNonExpired()); - assertEquals(userDetails2.isAccountNonExpired(), userDetailsWrapper2.isAccountNonExpired()); - } - - public void testIsAccountNonLocked() { - assertEquals(userDetails1.isAccountNonLocked(), userDetailsWrapper1.isAccountNonLocked()); - assertEquals(userDetails2.isAccountNonLocked(), userDetailsWrapper2.isAccountNonLocked()); - } - - public void testGetAuthorities() { - List expectedAuthorities = AuthorityUtils.createAuthorityList("ROLE_A", "ROLE_B"); - assertTrue(HierarchicalRolesTestHelper.containTheSameGrantedAuthorities(userDetailsWrapper1.getAuthorities(), expectedAuthorities)); - assertTrue(HierarchicalRolesTestHelper.containTheSameGrantedAuthorities(userDetailsWrapper2.getAuthorities(), expectedAuthorities)); - } - - public void testIsCredentialsNonExpired() { - assertEquals(userDetails1.isCredentialsNonExpired(), userDetailsWrapper1.isCredentialsNonExpired()); - assertEquals(userDetails2.isCredentialsNonExpired(), userDetailsWrapper2.isCredentialsNonExpired()); - } - - public void testIsEnabled() { - assertEquals(userDetails1.isEnabled(), userDetailsWrapper1.isEnabled()); - assertEquals(userDetails2.isEnabled(), userDetailsWrapper2.isEnabled()); - } - - public void testGetPassword() { - assertEquals(userDetails1.getPassword(), userDetailsWrapper1.getPassword()); - assertEquals(userDetails2.getPassword(), userDetailsWrapper2.getPassword()); - } - - public void testGetUsername() { - assertEquals(userDetails1.getUsername(), userDetailsWrapper1.getUsername()); - assertEquals(userDetails2.getUsername(), userDetailsWrapper2.getUsername()); - } - - public void testGetUnwrappedUserDetails() { - assertTrue(userDetailsWrapper1.getUnwrappedUserDetails() == userDetails1); - assertTrue(userDetailsWrapper2.getUnwrappedUserDetails() == userDetails2); - } - -} +package org.springframework.security.access.hierarchicalroles; + +import java.util.List; + +import junit.framework.TestCase; + +import org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl; +import org.springframework.security.access.hierarchicalroles.UserDetailsWrapper; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; + +/** + * Tests for {@link UserDetailsWrapper}. + * + * @author Michael Mayr + */ +@SuppressWarnings("deprecation") +public class UserDetailsWrapperTests extends TestCase { + + private List authorities = null; + private UserDetails userDetails1 = null; + private UserDetails userDetails2 = null; + private UserDetailsWrapper userDetailsWrapper1 = null; + private UserDetailsWrapper userDetailsWrapper2 = null; + + public UserDetailsWrapperTests() { + } + + public UserDetailsWrapperTests(String testCaseName) { + super(testCaseName); + } + + protected void setUp() throws Exception { + RoleHierarchyImpl roleHierarchy = new RoleHierarchyImpl(); + roleHierarchy.setHierarchy("ROLE_A > ROLE_B"); + authorities = AuthorityUtils.createAuthorityList("ROLE_A"); + userDetails1 = new User("TestUser1", "TestPassword1", true, true, true, true, authorities); + userDetails2 = new User("TestUser2", "TestPassword2", false, false, false, false, authorities); + userDetailsWrapper1 = new UserDetailsWrapper(userDetails1, roleHierarchy); + userDetailsWrapper2 = new UserDetailsWrapper(userDetails2, roleHierarchy); + } + + public void testIsAccountNonExpired() { + assertEquals(userDetails1.isAccountNonExpired(), userDetailsWrapper1.isAccountNonExpired()); + assertEquals(userDetails2.isAccountNonExpired(), userDetailsWrapper2.isAccountNonExpired()); + } + + public void testIsAccountNonLocked() { + assertEquals(userDetails1.isAccountNonLocked(), userDetailsWrapper1.isAccountNonLocked()); + assertEquals(userDetails2.isAccountNonLocked(), userDetailsWrapper2.isAccountNonLocked()); + } + + public void testGetAuthorities() { + List expectedAuthorities = AuthorityUtils.createAuthorityList("ROLE_A", "ROLE_B"); + assertTrue(HierarchicalRolesTestHelper.containTheSameGrantedAuthorities(userDetailsWrapper1.getAuthorities(), expectedAuthorities)); + assertTrue(HierarchicalRolesTestHelper.containTheSameGrantedAuthorities(userDetailsWrapper2.getAuthorities(), expectedAuthorities)); + } + + public void testIsCredentialsNonExpired() { + assertEquals(userDetails1.isCredentialsNonExpired(), userDetailsWrapper1.isCredentialsNonExpired()); + assertEquals(userDetails2.isCredentialsNonExpired(), userDetailsWrapper2.isCredentialsNonExpired()); + } + + public void testIsEnabled() { + assertEquals(userDetails1.isEnabled(), userDetailsWrapper1.isEnabled()); + assertEquals(userDetails2.isEnabled(), userDetailsWrapper2.isEnabled()); + } + + public void testGetPassword() { + assertEquals(userDetails1.getPassword(), userDetailsWrapper1.getPassword()); + assertEquals(userDetails2.getPassword(), userDetailsWrapper2.getPassword()); + } + + public void testGetUsername() { + assertEquals(userDetails1.getUsername(), userDetailsWrapper1.getUsername()); + assertEquals(userDetails2.getUsername(), userDetailsWrapper2.getUsername()); + } + + public void testGetUnwrappedUserDetails() { + assertTrue(userDetailsWrapper1.getUnwrappedUserDetails() == userDetails1); + assertTrue(userDetailsWrapper2.getUnwrappedUserDetails() == userDetails2); + } + +} diff --git a/core/src/test/java/org/springframework/security/access/intercept/AbstractSecurityInterceptorTests.java b/core/src/test/java/org/springframework/security/access/intercept/AbstractSecurityInterceptorTests.java index 1e6ef3938a..6f2bd62ef0 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/AbstractSecurityInterceptorTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/AbstractSecurityInterceptorTests.java @@ -32,7 +32,6 @@ import org.springframework.security.util.SimpleMethodInvocation; * MethodSecurityInterceptorTests class. * * @author Ben Alex - * @version $Id$ */ public class AbstractSecurityInterceptorTests { private Mockery jmock = new JUnit4Mockery(); diff --git a/core/src/test/java/org/springframework/security/access/intercept/AfterInvocationProviderManagerTests.java b/core/src/test/java/org/springframework/security/access/intercept/AfterInvocationProviderManagerTests.java index 701ff4d0fd..cf1f744b0a 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/AfterInvocationProviderManagerTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/AfterInvocationProviderManagerTests.java @@ -35,7 +35,6 @@ import org.springframework.security.util.SimpleMethodInvocation; * Tests {@link AfterInvocationProviderManager}. * * @author Ben Alex - * @version $Id$ */ @SuppressWarnings("unchecked") public class AfterInvocationProviderManagerTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/access/intercept/InterceptorStatusTokenTests.java b/core/src/test/java/org/springframework/security/access/intercept/InterceptorStatusTokenTests.java index 072a995a87..6e696c0b20 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/InterceptorStatusTokenTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/InterceptorStatusTokenTests.java @@ -33,7 +33,6 @@ import org.springframework.security.util.SimpleMethodInvocation; * Tests {@link InterceptorStatusToken}. * * @author Ben Alex - * @version $Id$ */ public class InterceptorStatusTokenTests { diff --git a/core/src/test/java/org/springframework/security/access/intercept/NullRunAsManagerTests.java b/core/src/test/java/org/springframework/security/access/intercept/NullRunAsManagerTests.java index fe331324ea..a32e0d32a9 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/NullRunAsManagerTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/NullRunAsManagerTests.java @@ -25,7 +25,6 @@ import org.springframework.security.access.intercept.NullRunAsManager; * Tests {@link NullRunAsManager}. * * @author Ben Alex - * @version $Id$ */ public class NullRunAsManagerTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/access/intercept/RunAsManagerImplTests.java b/core/src/test/java/org/springframework/security/access/intercept/RunAsManagerImplTests.java index 513bf7db53..e6e2b0979b 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/RunAsManagerImplTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/RunAsManagerImplTests.java @@ -29,7 +29,6 @@ import org.springframework.security.core.authority.AuthorityUtils; * Tests {@link RunAsManagerImpl}. * * @author Ben Alex - * @version $Id$ */ public class RunAsManagerImplTests extends TestCase { public void testAlwaysSupportsClass() { diff --git a/core/src/test/java/org/springframework/security/access/intercept/RunAsUserTokenTests.java b/core/src/test/java/org/springframework/security/access/intercept/RunAsUserTokenTests.java index 315c51b797..9a9841449a 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/RunAsUserTokenTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/RunAsUserTokenTests.java @@ -28,7 +28,6 @@ import org.springframework.security.core.authority.GrantedAuthorityImpl; * Tests {@link RunAsUserToken}. * * @author Ben Alex - * @version $Id$ */ public class RunAsUserTokenTests extends TestCase { //~ Constructors =================================================================================================== diff --git a/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptorTests.java b/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptorTests.java index 33747917a1..2624ce9af2 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptorTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptorTests.java @@ -50,7 +50,6 @@ import org.springframework.security.core.context.SecurityContextHolder; * Tests {@link MethodSecurityInterceptor}. * * @author Ben Alex - * @version $Id$ */ @SuppressWarnings("unchecked") public class MethodSecurityInterceptorTests { diff --git a/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityMetadataSourceAdvisorTests.java b/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityMetadataSourceAdvisorTests.java index 2633c850c7..8d2d54f3d3 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityMetadataSourceAdvisorTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityMetadataSourceAdvisorTests.java @@ -29,7 +29,6 @@ import org.springframework.security.access.method.MethodSecurityMetadataSourceEd * Tests {@link MethodSecurityMetadataSourceAdvisor}. * * @author Ben Alex - * @version $Id$ */ @SuppressWarnings("deprecation") public class MethodSecurityMetadataSourceAdvisorTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJSecurityInterceptorTests.java b/core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJSecurityInterceptorTests.java index d8a6cc9706..2f84f5863a 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJSecurityInterceptorTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJSecurityInterceptorTests.java @@ -42,7 +42,6 @@ import org.springframework.security.core.context.SecurityContextHolder; * Tests {@link AspectJSecurityInterceptor}. * * @author Ben Alex - * @version $Id$ */ public class AspectJSecurityInterceptorTests { private Mockery jmock = new JUnit4Mockery(); diff --git a/core/src/test/java/org/springframework/security/access/intercept/method/MethodInvocationPrivilegeEvaluatorTests.java b/core/src/test/java/org/springframework/security/access/intercept/method/MethodInvocationPrivilegeEvaluatorTests.java index 4e250177e4..489d4f0ecd 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/method/MethodInvocationPrivilegeEvaluatorTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/method/MethodInvocationPrivilegeEvaluatorTests.java @@ -45,7 +45,6 @@ import org.springframework.security.util.MethodInvocationUtils; * Tests {@link org.springframework.security.access.intercept.MethodInvocationPrivilegeEvaluator}. * * @author Ben Alex - * @version $Id$ */ public class MethodInvocationPrivilegeEvaluatorTests { private Mockery jmock = new JUnit4Mockery(); diff --git a/core/src/test/java/org/springframework/security/access/intercept/method/MethodSecurityMetadataSourceEditorTests.java b/core/src/test/java/org/springframework/security/access/intercept/method/MethodSecurityMetadataSourceEditorTests.java index 17ff50a85d..bbcbed3eeb 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/method/MethodSecurityMetadataSourceEditorTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/method/MethodSecurityMetadataSourceEditorTests.java @@ -37,7 +37,6 @@ import org.springframework.security.access.method.MethodSecurityMetadataSourceEd * Tests {@link MethodSecurityMetadataSourceEditor} and its associated {@link MapBasedMethodSecurityMetadataSource}. * * @author Ben Alex - * @version $Id$ */ @SuppressWarnings("deprecation") public class MethodSecurityMetadataSourceEditorTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/access/intercept/method/MockMethodSecurityMetadataSource.java b/core/src/test/java/org/springframework/security/access/intercept/method/MockMethodSecurityMetadataSource.java index c1d5cb0ca4..c33eee59e0 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/method/MockMethodSecurityMetadataSource.java +++ b/core/src/test/java/org/springframework/security/access/intercept/method/MockMethodSecurityMetadataSource.java @@ -29,7 +29,6 @@ import org.springframework.security.access.method.MethodSecurityMetadataSource; /** * @author Ben Alex - * @version $Id$ */ public class MockMethodSecurityMetadataSource implements MethodSecurityMetadataSource { //~ Instance fields ================================================================================================ diff --git a/core/src/test/java/org/springframework/security/access/vote/AbstractAccessDecisionManagerTests.java b/core/src/test/java/org/springframework/security/access/vote/AbstractAccessDecisionManagerTests.java index 60f27f6e67..63f1f21660 100644 --- a/core/src/test/java/org/springframework/security/access/vote/AbstractAccessDecisionManagerTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/AbstractAccessDecisionManagerTests.java @@ -34,7 +34,6 @@ import java.util.Vector; * Tests {@link AbstractAccessDecisionManager}. * * @author Ben Alex - * @version $Id$ */ @SuppressWarnings("unchecked") public class AbstractAccessDecisionManagerTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/access/vote/AbstractAclVoterTests.java b/core/src/test/java/org/springframework/security/access/vote/AbstractAclVoterTests.java index 614bc58c2a..b321f59312 100644 --- a/core/src/test/java/org/springframework/security/access/vote/AbstractAclVoterTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/AbstractAclVoterTests.java @@ -18,7 +18,6 @@ import org.springframework.security.util.MethodInvocationUtils; /** * * @author Luke Taylor - * @version $Id$ */ public class AbstractAclVoterTests { private AbstractAclVoter voter = new AbstractAclVoter() { diff --git a/core/src/test/java/org/springframework/security/access/vote/AffirmativeBasedTests.java b/core/src/test/java/org/springframework/security/access/vote/AffirmativeBasedTests.java index b9df043172..93403fb633 100644 --- a/core/src/test/java/org/springframework/security/access/vote/AffirmativeBasedTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/AffirmativeBasedTests.java @@ -36,7 +36,6 @@ import org.springframework.security.core.Authentication; * Tests {@link AffirmativeBased}. * * @author Ben Alex - * @version $Id$ */ public class AffirmativeBasedTests { private final List attrs = new ArrayList(); diff --git a/core/src/test/java/org/springframework/security/access/vote/AuthenticatedVoterTests.java b/core/src/test/java/org/springframework/security/access/vote/AuthenticatedVoterTests.java index 02828785a4..ef4f85e103 100644 --- a/core/src/test/java/org/springframework/security/access/vote/AuthenticatedVoterTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/AuthenticatedVoterTests.java @@ -34,7 +34,6 @@ import org.springframework.security.core.authority.AuthorityUtils; * Tests {@link AuthenticatedVoter}. * * @author Ben Alex - * @version $Id$ */ public class AuthenticatedVoterTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/access/vote/ConsensusBasedTests.java b/core/src/test/java/org/springframework/security/access/vote/ConsensusBasedTests.java index b3e1e895af..c4b1b1653b 100644 --- a/core/src/test/java/org/springframework/security/access/vote/ConsensusBasedTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/ConsensusBasedTests.java @@ -36,7 +36,6 @@ import org.springframework.security.core.authority.GrantedAuthorityImpl; * Tests {@link ConsensusBased}. * * @author Ben Alex - * @version $Id$ */ public class ConsensusBasedTests { diff --git a/core/src/test/java/org/springframework/security/access/vote/DenyAgainVoter.java b/core/src/test/java/org/springframework/security/access/vote/DenyAgainVoter.java index 9d0d6abd5a..236fce6643 100644 --- a/core/src/test/java/org/springframework/security/access/vote/DenyAgainVoter.java +++ b/core/src/test/java/org/springframework/security/access/vote/DenyAgainVoter.java @@ -31,7 +31,6 @@ import java.util.Iterator; * All comparisons are case sensitive. * * @author Ben Alex - * @version $Id$ */ public class DenyAgainVoter implements AccessDecisionVoter { // ~ Methods diff --git a/core/src/test/java/org/springframework/security/access/vote/DenyVoter.java b/core/src/test/java/org/springframework/security/access/vote/DenyVoter.java index 83bb56ace1..a660703309 100644 --- a/core/src/test/java/org/springframework/security/access/vote/DenyVoter.java +++ b/core/src/test/java/org/springframework/security/access/vote/DenyVoter.java @@ -29,7 +29,6 @@ import java.util.Iterator; *

All comparisons are case sensitive.

* * @author Ben Alex - * @version $Id$ */ public class DenyVoter implements AccessDecisionVoter { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/access/vote/LabelBasedAclVoterTests.java b/core/src/test/java/org/springframework/security/access/vote/LabelBasedAclVoterTests.java index 5ee8dde3af..c6772168ab 100644 --- a/core/src/test/java/org/springframework/security/access/vote/LabelBasedAclVoterTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/LabelBasedAclVoterTests.java @@ -32,7 +32,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Greg Turnquist - * @version $Id$ */ @ContextConfiguration(locations={"/org/springframework/security/vote/labelBasedSecurityApplicationContext.xml"}) @RunWith(SpringJUnit4ClassRunner.class) diff --git a/core/src/test/java/org/springframework/security/access/vote/RoleVoterTests.java b/core/src/test/java/org/springframework/security/access/vote/RoleVoterTests.java index 01c4afd991..148dd5a176 100644 --- a/core/src/test/java/org/springframework/security/access/vote/RoleVoterTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/RoleVoterTests.java @@ -11,7 +11,6 @@ import org.springframework.security.core.Authentication; /** * * @author Luke Taylor - * @version $Id$ */ public class RoleVoterTests { @Test diff --git a/core/src/test/java/org/springframework/security/access/vote/SampleBlockOfData.java b/core/src/test/java/org/springframework/security/access/vote/SampleBlockOfData.java index 3d71ed77a4..42ca005f09 100644 --- a/core/src/test/java/org/springframework/security/access/vote/SampleBlockOfData.java +++ b/core/src/test/java/org/springframework/security/access/vote/SampleBlockOfData.java @@ -24,7 +24,6 @@ import java.io.Serializable; * For label unit tests. * * @author Greg Turnquist - * @version $Id$ */ public class SampleBlockOfData implements Serializable, LabeledData { //~ Static fields/initializers ===================================================================================== diff --git a/core/src/test/java/org/springframework/security/access/vote/SampleService.java b/core/src/test/java/org/springframework/security/access/vote/SampleService.java index 10776815c7..30437bbaf0 100644 --- a/core/src/test/java/org/springframework/security/access/vote/SampleService.java +++ b/core/src/test/java/org/springframework/security/access/vote/SampleService.java @@ -20,7 +20,6 @@ import java.util.List; /** * @author Greg Turnquist - * @version $Id$ */ public interface SampleService { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/access/vote/SampleServiceImpl.java b/core/src/test/java/org/springframework/security/access/vote/SampleServiceImpl.java index 95291649f6..aa9bf9d4f4 100644 --- a/core/src/test/java/org/springframework/security/access/vote/SampleServiceImpl.java +++ b/core/src/test/java/org/springframework/security/access/vote/SampleServiceImpl.java @@ -22,7 +22,6 @@ import java.util.Vector; * For label unit tests. * * @author Greg Turnquist - * @version $Id$ */ public class SampleServiceImpl implements SampleService { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/access/vote/SomeDomainObject.java b/core/src/test/java/org/springframework/security/access/vote/SomeDomainObject.java index 3e9133cc02..28712a935d 100644 --- a/core/src/test/java/org/springframework/security/access/vote/SomeDomainObject.java +++ b/core/src/test/java/org/springframework/security/access/vote/SomeDomainObject.java @@ -19,7 +19,6 @@ package org.springframework.security.access.vote; * Simple domain object, used by {@link BasicAclEntryVoterTests}. * * @author Ben Alex - * @version $Id$ */ public class SomeDomainObject { //~ Instance fields ================================================================================================ diff --git a/core/src/test/java/org/springframework/security/access/vote/SomeDomainObjectManager.java b/core/src/test/java/org/springframework/security/access/vote/SomeDomainObjectManager.java index cca5e0ffdd..762fc0861a 100644 --- a/core/src/test/java/org/springframework/security/access/vote/SomeDomainObjectManager.java +++ b/core/src/test/java/org/springframework/security/access/vote/SomeDomainObjectManager.java @@ -20,7 +20,6 @@ package org.springframework.security.access.vote; * SomeDomainObject. * * @author Ben Alex - * @version $Id$ */ public class SomeDomainObjectManager { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/access/vote/UnanimousBasedTests.java b/core/src/test/java/org/springframework/security/access/vote/UnanimousBasedTests.java index a190f6dcb3..7513593307 100644 --- a/core/src/test/java/org/springframework/security/access/vote/UnanimousBasedTests.java +++ b/core/src/test/java/org/springframework/security/access/vote/UnanimousBasedTests.java @@ -33,7 +33,6 @@ import org.springframework.security.authentication.TestingAuthenticationToken; * Tests {@link UnanimousBased}. * * @author Ben Alex - * @version $Id$ */ public class UnanimousBasedTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/authentication/AbstractAuthenticationTokenTests.java b/core/src/test/java/org/springframework/security/authentication/AbstractAuthenticationTokenTests.java index 5d2190eae8..908831c626 100644 --- a/core/src/test/java/org/springframework/security/authentication/AbstractAuthenticationTokenTests.java +++ b/core/src/test/java/org/springframework/security/authentication/AbstractAuthenticationTokenTests.java @@ -30,7 +30,6 @@ import org.springframework.security.core.authority.GrantedAuthorityImpl; * Tests {@link AbstractAuthenticationToken}. * * @author Ben Alex - * @version $Id$ */ public class AbstractAuthenticationTokenTests { //~ Instance fields ================================================================================================ diff --git a/core/src/test/java/org/springframework/security/authentication/AuthenticationDetailsSourceImplTests.java b/core/src/test/java/org/springframework/security/authentication/AuthenticationDetailsSourceImplTests.java index ec6a984ab9..afc63f6ddc 100644 --- a/core/src/test/java/org/springframework/security/authentication/AuthenticationDetailsSourceImplTests.java +++ b/core/src/test/java/org/springframework/security/authentication/AuthenticationDetailsSourceImplTests.java @@ -10,7 +10,6 @@ import org.springframework.security.authentication.TestingAuthenticationToken; /** * * @author Luke Taylor - * @version $Id$ */ public class AuthenticationDetailsSourceImplTests { diff --git a/core/src/test/java/org/springframework/security/authentication/AuthenticationTrustResolverImplTests.java b/core/src/test/java/org/springframework/security/authentication/AuthenticationTrustResolverImplTests.java index 5da9dcaab8..9acd77f182 100644 --- a/core/src/test/java/org/springframework/security/authentication/AuthenticationTrustResolverImplTests.java +++ b/core/src/test/java/org/springframework/security/authentication/AuthenticationTrustResolverImplTests.java @@ -28,7 +28,6 @@ import org.springframework.security.core.authority.AuthorityUtils; * Tests {@link org.springframework.security.authentication.AuthenticationTrustResolverImpl}. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationTrustResolverImplTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/authentication/ProviderManagerTests.java b/core/src/test/java/org/springframework/security/authentication/ProviderManagerTests.java index f63bc66140..a8ec61c75f 100644 --- a/core/src/test/java/org/springframework/security/authentication/ProviderManagerTests.java +++ b/core/src/test/java/org/springframework/security/authentication/ProviderManagerTests.java @@ -34,7 +34,6 @@ import org.springframework.security.core.authority.AuthorityUtils; * Tests {@link ProviderManager}. * * @author Ben Alex - * @version $Id$ */ @SuppressWarnings("unchecked") public class ProviderManagerTests { diff --git a/core/src/test/java/org/springframework/security/authentication/TestingAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/authentication/TestingAuthenticationProviderTests.java index 5ce1a7aaf6..882c3b49ba 100644 --- a/core/src/test/java/org/springframework/security/authentication/TestingAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/TestingAuthenticationProviderTests.java @@ -26,7 +26,6 @@ import org.springframework.security.core.authority.AuthorityUtils; * Tests {@link TestingAuthenticationProvider}. * * @author Ben Alex - * @version $Id$ */ public class TestingAuthenticationProviderTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/authentication/UsernamePasswordAuthenticationTokenTests.java b/core/src/test/java/org/springframework/security/authentication/UsernamePasswordAuthenticationTokenTests.java index 1274c4220d..d0218727be 100644 --- a/core/src/test/java/org/springframework/security/authentication/UsernamePasswordAuthenticationTokenTests.java +++ b/core/src/test/java/org/springframework/security/authentication/UsernamePasswordAuthenticationTokenTests.java @@ -28,7 +28,6 @@ import org.springframework.security.core.authority.AuthorityUtils; * Tests {@link UsernamePasswordAuthenticationToken}. * * @author Ben Alex - * @version $Id$ */ public class UsernamePasswordAuthenticationTokenTests { diff --git a/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationProviderTests.java index 437c4467e5..b3ac39db73 100644 --- a/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationProviderTests.java @@ -32,7 +32,6 @@ import org.springframework.security.core.authority.GrantedAuthorityImpl; * Tests {@link AnonymousAuthenticationProvider}. * * @author Ben Alex - * @version $Id$ */ public class AnonymousAuthenticationProviderTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationTokenTests.java b/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationTokenTests.java index ef7185e520..dc61388a9c 100644 --- a/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationTokenTests.java +++ b/core/src/test/java/org/springframework/security/authentication/anonymous/AnonymousAuthenticationTokenTests.java @@ -29,7 +29,6 @@ import org.springframework.security.core.authority.AuthorityUtils; * Tests {@link AnonymousAuthenticationToken}. * * @author Ben Alex - * @version $Id$ */ public class AnonymousAuthenticationTokenTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/authentication/dao/DaoAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/authentication/dao/DaoAuthenticationProviderTests.java index 85cec8fa28..4d1b9365ac 100644 --- a/core/src/test/java/org/springframework/security/authentication/dao/DaoAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/dao/DaoAuthenticationProviderTests.java @@ -45,7 +45,6 @@ import org.springframework.security.core.userdetails.cache.NullUserCache; * Tests {@link DaoAuthenticationProvider}. * * @author Ben Alex - * @version $Id$ */ public class DaoAuthenticationProviderTests extends TestCase { private static final List ROLES_12 = AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"); diff --git a/core/src/test/java/org/springframework/security/authentication/dao/salt/ReflectionSaltSourceTests.java b/core/src/test/java/org/springframework/security/authentication/dao/salt/ReflectionSaltSourceTests.java index 483c68bb23..893605a7b1 100644 --- a/core/src/test/java/org/springframework/security/authentication/dao/salt/ReflectionSaltSourceTests.java +++ b/core/src/test/java/org/springframework/security/authentication/dao/salt/ReflectionSaltSourceTests.java @@ -28,7 +28,6 @@ import org.springframework.security.core.userdetails.UserDetails; * Tests {@link ReflectionSaltSource}. * * @author Ben Alex - * @version $Id$ */ public class ReflectionSaltSourceTests { private UserDetails user = new User("scott", "wombat", true, true, true, true, diff --git a/core/src/test/java/org/springframework/security/authentication/dao/salt/SystemWideSaltSourceTests.java b/core/src/test/java/org/springframework/security/authentication/dao/salt/SystemWideSaltSourceTests.java index 2a46b57007..9e512b54a4 100644 --- a/core/src/test/java/org/springframework/security/authentication/dao/salt/SystemWideSaltSourceTests.java +++ b/core/src/test/java/org/springframework/security/authentication/dao/salt/SystemWideSaltSourceTests.java @@ -24,7 +24,6 @@ import junit.framework.TestCase; * Tests {@link SystemWideSaltSource}. * * @author Ben Alex - * @version $Id$ */ public class SystemWideSaltSourceTests extends TestCase { //~ Constructors =================================================================================================== diff --git a/core/src/test/java/org/springframework/security/authentication/encoding/BasePasswordEncoderTests.java b/core/src/test/java/org/springframework/security/authentication/encoding/BasePasswordEncoderTests.java index 600050fdce..a1148a88e8 100644 --- a/core/src/test/java/org/springframework/security/authentication/encoding/BasePasswordEncoderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/encoding/BasePasswordEncoderTests.java @@ -25,7 +25,6 @@ import org.springframework.security.authentication.encoding.BasePasswordEncoder; *

TestCase for BasePasswordEncoder.

* * @author Ben Alex - * @version $Id$ */ public class BasePasswordEncoderTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/authentication/encoding/Md4PasswordEncoderTests.java b/core/src/test/java/org/springframework/security/authentication/encoding/Md4PasswordEncoderTests.java index 619f5b9cef..57777b2eb8 100644 --- a/core/src/test/java/org/springframework/security/authentication/encoding/Md4PasswordEncoderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/encoding/Md4PasswordEncoderTests.java @@ -1,73 +1,73 @@ -/* Copyright 2004, 2005, 2006, 2007 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.security.authentication.encoding; - -import org.springframework.security.authentication.encoding.Md4PasswordEncoder; - -import junit.framework.TestCase; - -public class Md4PasswordEncoderTests extends TestCase { - - public void testEncodeUnsaltedPassword() { - Md4PasswordEncoder md4 = new Md4PasswordEncoder(); - md4.setEncodeHashAsBase64(true); - String encodedPassword = md4.encodePassword("ww_uni123", null); - assertEquals("8zobtq72iAt0W6KNqavGwg==", encodedPassword); - } - - public void testEncodeSaltedPassword() { - Md4PasswordEncoder md4 = new Md4PasswordEncoder(); - md4.setEncodeHashAsBase64(true); - String encodedPassword = md4.encodePassword("ww_uni123", "Alan K Stewart"); - assertEquals("ZplT6P5Kv6Rlu6W4FIoYNA==", encodedPassword); - } - - public void testEncodeNullPassword() { - Md4PasswordEncoder md4 = new Md4PasswordEncoder(); - md4.setEncodeHashAsBase64(true); - String encodedPassword = md4.encodePassword(null, null); - assertEquals("MdbP4NFq6TG3PFnX4MCJwA==", encodedPassword); - } - - public void testEncodeEmptyPassword() { - Md4PasswordEncoder md4 = new Md4PasswordEncoder(); - md4.setEncodeHashAsBase64(true); - String encodedPassword = md4.encodePassword("", null); - assertEquals("MdbP4NFq6TG3PFnX4MCJwA==", encodedPassword); - } - - public void testNonAsciiPasswordHasCorrectHash() { - Md4PasswordEncoder md4 = new Md4PasswordEncoder(); - String encodedPassword = md4.encodePassword("\u4F60\u597d", null); - assertEquals("a7f1196539fd1f85f754ffd185b16e6e", encodedPassword); - } - - public void testIsHexPasswordValid() { - Md4PasswordEncoder md4 = new Md4PasswordEncoder(); - assertTrue(md4.isPasswordValid("31d6cfe0d16ae931b73c59d7e0c089c0", "", null)); - } - - public void testIsPasswordValid() { - Md4PasswordEncoder md4 = new Md4PasswordEncoder(); - md4.setEncodeHashAsBase64(true); - assertTrue(md4.isPasswordValid("8zobtq72iAt0W6KNqavGwg==", "ww_uni123", null)); - } - - public void testIsSaltedPasswordValid() { - Md4PasswordEncoder md4 = new Md4PasswordEncoder(); - md4.setEncodeHashAsBase64(true); - assertTrue(md4.isPasswordValid("ZplT6P5Kv6Rlu6W4FIoYNA==", "ww_uni123", "Alan K Stewart")); - } -} +/* Copyright 2004, 2005, 2006, 2007 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.security.authentication.encoding; + +import org.springframework.security.authentication.encoding.Md4PasswordEncoder; + +import junit.framework.TestCase; + +public class Md4PasswordEncoderTests extends TestCase { + + public void testEncodeUnsaltedPassword() { + Md4PasswordEncoder md4 = new Md4PasswordEncoder(); + md4.setEncodeHashAsBase64(true); + String encodedPassword = md4.encodePassword("ww_uni123", null); + assertEquals("8zobtq72iAt0W6KNqavGwg==", encodedPassword); + } + + public void testEncodeSaltedPassword() { + Md4PasswordEncoder md4 = new Md4PasswordEncoder(); + md4.setEncodeHashAsBase64(true); + String encodedPassword = md4.encodePassword("ww_uni123", "Alan K Stewart"); + assertEquals("ZplT6P5Kv6Rlu6W4FIoYNA==", encodedPassword); + } + + public void testEncodeNullPassword() { + Md4PasswordEncoder md4 = new Md4PasswordEncoder(); + md4.setEncodeHashAsBase64(true); + String encodedPassword = md4.encodePassword(null, null); + assertEquals("MdbP4NFq6TG3PFnX4MCJwA==", encodedPassword); + } + + public void testEncodeEmptyPassword() { + Md4PasswordEncoder md4 = new Md4PasswordEncoder(); + md4.setEncodeHashAsBase64(true); + String encodedPassword = md4.encodePassword("", null); + assertEquals("MdbP4NFq6TG3PFnX4MCJwA==", encodedPassword); + } + + public void testNonAsciiPasswordHasCorrectHash() { + Md4PasswordEncoder md4 = new Md4PasswordEncoder(); + String encodedPassword = md4.encodePassword("\u4F60\u597d", null); + assertEquals("a7f1196539fd1f85f754ffd185b16e6e", encodedPassword); + } + + public void testIsHexPasswordValid() { + Md4PasswordEncoder md4 = new Md4PasswordEncoder(); + assertTrue(md4.isPasswordValid("31d6cfe0d16ae931b73c59d7e0c089c0", "", null)); + } + + public void testIsPasswordValid() { + Md4PasswordEncoder md4 = new Md4PasswordEncoder(); + md4.setEncodeHashAsBase64(true); + assertTrue(md4.isPasswordValid("8zobtq72iAt0W6KNqavGwg==", "ww_uni123", null)); + } + + public void testIsSaltedPasswordValid() { + Md4PasswordEncoder md4 = new Md4PasswordEncoder(); + md4.setEncodeHashAsBase64(true); + assertTrue(md4.isPasswordValid("ZplT6P5Kv6Rlu6W4FIoYNA==", "ww_uni123", "Alan K Stewart")); + } +} diff --git a/core/src/test/java/org/springframework/security/authentication/encoding/Md5PasswordEncoderTests.java b/core/src/test/java/org/springframework/security/authentication/encoding/Md5PasswordEncoderTests.java index f457dd66ed..bb66604f1e 100644 --- a/core/src/test/java/org/springframework/security/authentication/encoding/Md5PasswordEncoderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/encoding/Md5PasswordEncoderTests.java @@ -26,7 +26,6 @@ import junit.framework.TestCase; * @author colin sampaleanu * @author Ben Alex * @author Ray Krueger - * @version $Id$ */ public class Md5PasswordEncoderTests extends TestCase { //~ Methods ======================================================================================================== @@ -42,12 +41,12 @@ public class Md5PasswordEncoderTests extends TestCase { assertEquals("a68aafd90299d0b137de28fb4bb68573", encoded); assertEquals("MD5", pe.getAlgorithm()); } - + public void testNonAsciiPasswordHasCorrectHash() { Md5PasswordEncoder md5 = new Md5PasswordEncoder(); String encodedPassword = md5.encodePassword("\u4F60\u597d", null); - assertEquals("7eca689f0d3389d9dea66ae112e5cfd7", encodedPassword); - } + assertEquals("7eca689f0d3389d9dea66ae112e5cfd7", encodedPassword); + } public void testBase64() throws Exception { Md5PasswordEncoder pe = new Md5PasswordEncoder(); diff --git a/core/src/test/java/org/springframework/security/authentication/encoding/PlaintextPasswordEncoderTests.java b/core/src/test/java/org/springframework/security/authentication/encoding/PlaintextPasswordEncoderTests.java index 50fcf9a3c1..1e15fcbd41 100644 --- a/core/src/test/java/org/springframework/security/authentication/encoding/PlaintextPasswordEncoderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/encoding/PlaintextPasswordEncoderTests.java @@ -25,7 +25,6 @@ import junit.framework.TestCase; * * @author colin sampaleanu * @author Ben Alex - * @version $Id$ */ public class PlaintextPasswordEncoderTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/authentication/encoding/ShaPasswordEncoderTests.java b/core/src/test/java/org/springframework/security/authentication/encoding/ShaPasswordEncoderTests.java index 270d421324..913bb38d8b 100644 --- a/core/src/test/java/org/springframework/security/authentication/encoding/ShaPasswordEncoderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/encoding/ShaPasswordEncoderTests.java @@ -26,7 +26,6 @@ import junit.framework.TestCase; * @author colin sampaleanu * @author Ben Alex * @author Ray Krueger - * @version $Id$ */ public class ShaPasswordEncoderTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/authentication/event/AuthenticationEventTests.java b/core/src/test/java/org/springframework/security/authentication/event/AuthenticationEventTests.java index 0b0a2fb174..ce57bba42a 100644 --- a/core/src/test/java/org/springframework/security/authentication/event/AuthenticationEventTests.java +++ b/core/src/test/java/org/springframework/security/authentication/event/AuthenticationEventTests.java @@ -32,7 +32,6 @@ import org.springframework.security.core.AuthenticationException; * Tests {@link AbstractAuthenticationEvent} and its subclasses. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationEventTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/authentication/event/LoggerListenerTests.java b/core/src/test/java/org/springframework/security/authentication/event/LoggerListenerTests.java index 8ac74d48ff..3bed46b166 100644 --- a/core/src/test/java/org/springframework/security/authentication/event/LoggerListenerTests.java +++ b/core/src/test/java/org/springframework/security/authentication/event/LoggerListenerTests.java @@ -29,7 +29,6 @@ import org.springframework.security.core.Authentication; * Tests {@link LoggerListener}. * * @author Ben Alex - * @version $Id$ */ public class LoggerListenerTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/authentication/jaas/JaasAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/authentication/jaas/JaasAuthenticationProviderTests.java index 7f7a117b9d..c922d35729 100644 --- a/core/src/test/java/org/springframework/security/authentication/jaas/JaasAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/jaas/JaasAuthenticationProviderTests.java @@ -50,7 +50,6 @@ import org.springframework.security.core.session.SessionDestroyedEvent; * Tests for the JaasAuthenticationProvider * * @author Ray Krueger - * @version $Id$ */ public class JaasAuthenticationProviderTests { //~ Instance fields ================================================================================================ diff --git a/core/src/test/java/org/springframework/security/authentication/jaas/JaasEventCheck.java b/core/src/test/java/org/springframework/security/authentication/jaas/JaasEventCheck.java index 129bb06ff8..2024566138 100644 --- a/core/src/test/java/org/springframework/security/authentication/jaas/JaasEventCheck.java +++ b/core/src/test/java/org/springframework/security/authentication/jaas/JaasEventCheck.java @@ -23,7 +23,6 @@ import org.springframework.security.authentication.jaas.event.JaasAuthentication /** * @author Ray Krueger - * @version $Id$ */ public class JaasEventCheck implements ApplicationListener { //~ Instance fields ================================================================================================ diff --git a/core/src/test/java/org/springframework/security/authentication/jaas/TestAuthorityGranter.java b/core/src/test/java/org/springframework/security/authentication/jaas/TestAuthorityGranter.java index 199a136e58..8405a3b201 100644 --- a/core/src/test/java/org/springframework/security/authentication/jaas/TestAuthorityGranter.java +++ b/core/src/test/java/org/springframework/security/authentication/jaas/TestAuthorityGranter.java @@ -26,7 +26,6 @@ import org.springframework.security.authentication.jaas.AuthorityGranter; /** * * @author Ray Krueger - * @version $Id$ */ public class TestAuthorityGranter implements AuthorityGranter { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/authentication/jaas/TestCallbackHandler.java b/core/src/test/java/org/springframework/security/authentication/jaas/TestCallbackHandler.java index 386418eb2a..90e0de9de9 100644 --- a/core/src/test/java/org/springframework/security/authentication/jaas/TestCallbackHandler.java +++ b/core/src/test/java/org/springframework/security/authentication/jaas/TestCallbackHandler.java @@ -29,7 +29,6 @@ import javax.security.auth.callback.UnsupportedCallbackException; * TestCallbackHandler * * @author Ray Krueger - * @version $Id$ */ public class TestCallbackHandler implements JaasAuthenticationCallbackHandler { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/authentication/jaas/TestLoginModule.java b/core/src/test/java/org/springframework/security/authentication/jaas/TestLoginModule.java index 5d3602c74f..e19565b999 100644 --- a/core/src/test/java/org/springframework/security/authentication/jaas/TestLoginModule.java +++ b/core/src/test/java/org/springframework/security/authentication/jaas/TestLoginModule.java @@ -27,7 +27,6 @@ import javax.security.auth.spi.LoginModule; /** * @author Ray Krueger - * @version $Id$ */ public class TestLoginModule implements LoginModule { //~ Instance fields ================================================================================================ diff --git a/core/src/test/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManagerImplTests.java b/core/src/test/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManagerImplTests.java index 6c4b0e0764..4a6ddd478c 100644 --- a/core/src/test/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManagerImplTests.java +++ b/core/src/test/java/org/springframework/security/authentication/rcp/RemoteAuthenticationManagerImplTests.java @@ -26,7 +26,6 @@ import org.springframework.security.authentication.rcp.RemoteAuthenticationManag * Tests {@link RemoteAuthenticationManagerImpl}. * * @author Ben Alex - * @version $Id$ */ public class RemoteAuthenticationManagerImplTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/authentication/rcp/RemoteAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/authentication/rcp/RemoteAuthenticationProviderTests.java index e8fc833574..52c2f96ebf 100644 --- a/core/src/test/java/org/springframework/security/authentication/rcp/RemoteAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/rcp/RemoteAuthenticationProviderTests.java @@ -29,7 +29,6 @@ import org.springframework.security.core.authority.AuthorityUtils; * Tests {@link RemoteAuthenticationProvider}. * * @author Ben Alex - * @version $Id$ */ public class RemoteAuthenticationProviderTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/authentication/rememberme/RememberMeAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/authentication/rememberme/RememberMeAuthenticationProviderTests.java index 4ac55aba12..75345ac77f 100644 --- a/core/src/test/java/org/springframework/security/authentication/rememberme/RememberMeAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/rememberme/RememberMeAuthenticationProviderTests.java @@ -29,7 +29,6 @@ import org.springframework.security.core.authority.AuthorityUtils; * Tests {@link RememberMeAuthenticationProvider}. * * @author Ben Alex - * @version $Id$ */ public class RememberMeAuthenticationProviderTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/authentication/rememberme/RememberMeAuthenticationTokenTests.java b/core/src/test/java/org/springframework/security/authentication/rememberme/RememberMeAuthenticationTokenTests.java index b7b68f5ab1..ca7a36e54b 100644 --- a/core/src/test/java/org/springframework/security/authentication/rememberme/RememberMeAuthenticationTokenTests.java +++ b/core/src/test/java/org/springframework/security/authentication/rememberme/RememberMeAuthenticationTokenTests.java @@ -29,7 +29,6 @@ import org.springframework.security.core.authority.AuthorityUtils; * Tests {@link RememberMeAuthenticationToken}. * * @author Ben Alex - * @version $Id$ */ public class RememberMeAuthenticationTokenTests extends TestCase { private static final List ROLES_12 = AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"); diff --git a/core/src/test/java/org/springframework/security/core/authority/AuthorityUtilsTests.java b/core/src/test/java/org/springframework/security/core/authority/AuthorityUtilsTests.java index f991b3d57e..1a59aece11 100644 --- a/core/src/test/java/org/springframework/security/core/authority/AuthorityUtilsTests.java +++ b/core/src/test/java/org/springframework/security/core/authority/AuthorityUtilsTests.java @@ -11,7 +11,6 @@ import org.springframework.security.core.authority.AuthorityUtils; /** * @author Luke Taylor - * @version $Id$ */ public class AuthorityUtilsTests { diff --git a/core/src/test/java/org/springframework/security/core/authority/GrantedAuthorityImplTests.java b/core/src/test/java/org/springframework/security/core/authority/GrantedAuthorityImplTests.java index fb308fa3ca..b896245684 100644 --- a/core/src/test/java/org/springframework/security/core/authority/GrantedAuthorityImplTests.java +++ b/core/src/test/java/org/springframework/security/core/authority/GrantedAuthorityImplTests.java @@ -26,7 +26,6 @@ import org.springframework.security.core.authority.GrantedAuthorityImpl; * Tests {@link GrantedAuthorityImpl}. * * @author Ben Alex - * @version $Id$ */ public class GrantedAuthorityImplTests { diff --git a/core/src/test/java/org/springframework/security/core/authority/mapping/MapBasedAttributes2GrantedAuthoritiesMapperTest.java b/core/src/test/java/org/springframework/security/core/authority/mapping/MapBasedAttributes2GrantedAuthoritiesMapperTest.java index 92d4fccf31..2b7f9c4bf9 100755 --- a/core/src/test/java/org/springframework/security/core/authority/mapping/MapBasedAttributes2GrantedAuthoritiesMapperTest.java +++ b/core/src/test/java/org/springframework/security/core/authority/mapping/MapBasedAttributes2GrantedAuthoritiesMapperTest.java @@ -1,210 +1,210 @@ -package org.springframework.security.core.authority.mapping; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; - -import org.junit.Test; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthorityImpl; -import org.springframework.security.core.authority.mapping.Attributes2GrantedAuthoritiesMapper; -import org.springframework.security.core.authority.mapping.MapBasedAttributes2GrantedAuthoritiesMapper; - -/** - * - * @author Ruud Senden - */ -@SuppressWarnings("unchecked") -public class MapBasedAttributes2GrantedAuthoritiesMapperTest { - - @Test(expected=IllegalArgumentException.class) - public void testAfterPropertiesSetNoMap() throws Exception { - MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); - mapper.afterPropertiesSet(); - } - - @Test(expected=IllegalArgumentException.class) - public void testAfterPropertiesSetEmptyMap() throws Exception { - MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); - mapper.setAttributes2grantedAuthoritiesMap(new HashMap()); - mapper.afterPropertiesSet(); - } - - @Test(expected=IllegalArgumentException.class) - public void testAfterPropertiesSetInvalidKeyTypeMap() throws Exception { - MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); - HashMap m = new HashMap(); - m.put(new Object(),"ga1"); - mapper.setAttributes2grantedAuthoritiesMap(m); - mapper.afterPropertiesSet(); - } - - @Test(expected=IllegalArgumentException.class) - public void testAfterPropertiesSetInvalidValueTypeMap1() throws Exception { - MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); - HashMap m = new HashMap(); - m.put("role1",new Object()); - mapper.setAttributes2grantedAuthoritiesMap(m); - mapper.afterPropertiesSet(); - } - - @Test(expected=IllegalArgumentException.class) - public void testAfterPropertiesSetInvalidValueTypeMap2() throws Exception { - MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); - HashMap m = new HashMap(); - m.put("role1",new Object[]{new String[]{"ga1","ga2"}, new Object()}); - mapper.setAttributes2grantedAuthoritiesMap(m); - mapper.afterPropertiesSet(); - } - - @Test - public void testAfterPropertiesSetValidMap() throws Exception { - MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); - HashMap m = getValidAttributes2GrantedAuthoritiesMap(); - mapper.setAttributes2grantedAuthoritiesMap(m); - mapper.afterPropertiesSet(); - } - - @Test - public void testMapping1() throws Exception { - String[] roles = { "role1" }; - String[] expectedGas = { "ga1" }; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - @Test - public void testMapping2() throws Exception { - String[] roles = { "role2" }; - String[] expectedGas = { "ga2" }; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - @Test - public void testMapping3() throws Exception { - String[] roles = { "role3" }; - String[] expectedGas = { "ga3", "ga4" }; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - @Test - public void testMapping4() throws Exception { - String[] roles = { "role4" }; - String[] expectedGas = { "ga5", "ga6" }; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - @Test - public void testMapping5() throws Exception { - String[] roles = { "role5" }; - String[] expectedGas = { "ga7", "ga8", "ga9" }; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - @Test - public void testMapping6() throws Exception { - String[] roles = { "role6" }; - String[] expectedGas = { "ga10", "ga11", "ga12" }; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - @Test - public void testMapping7() throws Exception { - String[] roles = { "role7" }; - String[] expectedGas = { "ga13", "ga14" }; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - @Test - public void testMapping8() throws Exception { - String[] roles = { "role8" }; - String[] expectedGas = { "ga13", "ga14" }; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - @Test - public void testMapping9() throws Exception { - String[] roles = { "role9" }; - String[] expectedGas = {}; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - @Test - public void testMapping10() throws Exception { - String[] roles = { "role10" }; - String[] expectedGas = {}; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - @Test - public void testMapping11() throws Exception { - String[] roles = { "role11" }; - String[] expectedGas = {}; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - @Test - public void testNonExistingMapping() throws Exception { - String[] roles = { "nonExisting" }; - String[] expectedGas = {}; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - @Test - public void testMappingCombination() throws Exception { - String[] roles = { "role1", "role2", "role3", "role4", "role5", "role6", "role7", "role8", "role9", "role10", "role11" }; - String[] expectedGas = { "ga1", "ga2", "ga3", "ga4", "ga5", "ga6", "ga7", "ga8", "ga9", "ga10", "ga11", "ga12", "ga13", "ga14"}; - Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - private HashMap getValidAttributes2GrantedAuthoritiesMap() { - HashMap m = new HashMap(); - m.put("role1","ga1"); - m.put("role2",new GrantedAuthorityImpl("ga2")); - m.put("role3",Arrays.asList(new Object[]{"ga3",new GrantedAuthorityImpl("ga4")})); - m.put("role4","ga5,ga6"); - m.put("role5",Arrays.asList(new Object[]{"ga7","ga8",new Object[]{new GrantedAuthorityImpl("ga9")}})); - m.put("role6",new Object[]{"ga10","ga11",new Object[]{new GrantedAuthorityImpl("ga12")}}); - m.put("role7",new String[]{"ga13","ga14"}); - m.put("role8",new String[]{"ga13","ga14",null}); - m.put("role9",null); - m.put("role10",new Object[]{}); - m.put("role11",Arrays.asList(new Object[]{null})); - return m; - } - - private MapBasedAttributes2GrantedAuthoritiesMapper getDefaultMapper() throws Exception { - MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); - mapper.setAttributes2grantedAuthoritiesMap(getValidAttributes2GrantedAuthoritiesMap()); - mapper.afterPropertiesSet(); - return mapper; - } - - private void testGetGrantedAuthorities(Attributes2GrantedAuthoritiesMapper mapper, String[] roles, String[] expectedGas) { - List result = mapper.getGrantedAuthorities(Arrays.asList(roles)); - Collection resultColl = new ArrayList(result.size()); - for (int i = 0; i < result.size(); i++) { - resultColl.add(result.get(i).getAuthority()); - } - Collection expectedColl = Arrays.asList(expectedGas); - assertTrue("Role collections should match; result: " + resultColl + ", expected: " + expectedColl, expectedColl - .containsAll(resultColl) - && resultColl.containsAll(expectedColl)); - } -} +package org.springframework.security.core.authority.mapping; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; + +import org.junit.Test; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.GrantedAuthorityImpl; +import org.springframework.security.core.authority.mapping.Attributes2GrantedAuthoritiesMapper; +import org.springframework.security.core.authority.mapping.MapBasedAttributes2GrantedAuthoritiesMapper; + +/** + * + * @author Ruud Senden + */ +@SuppressWarnings("unchecked") +public class MapBasedAttributes2GrantedAuthoritiesMapperTest { + + @Test(expected=IllegalArgumentException.class) + public void testAfterPropertiesSetNoMap() throws Exception { + MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); + mapper.afterPropertiesSet(); + } + + @Test(expected=IllegalArgumentException.class) + public void testAfterPropertiesSetEmptyMap() throws Exception { + MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); + mapper.setAttributes2grantedAuthoritiesMap(new HashMap()); + mapper.afterPropertiesSet(); + } + + @Test(expected=IllegalArgumentException.class) + public void testAfterPropertiesSetInvalidKeyTypeMap() throws Exception { + MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); + HashMap m = new HashMap(); + m.put(new Object(),"ga1"); + mapper.setAttributes2grantedAuthoritiesMap(m); + mapper.afterPropertiesSet(); + } + + @Test(expected=IllegalArgumentException.class) + public void testAfterPropertiesSetInvalidValueTypeMap1() throws Exception { + MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); + HashMap m = new HashMap(); + m.put("role1",new Object()); + mapper.setAttributes2grantedAuthoritiesMap(m); + mapper.afterPropertiesSet(); + } + + @Test(expected=IllegalArgumentException.class) + public void testAfterPropertiesSetInvalidValueTypeMap2() throws Exception { + MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); + HashMap m = new HashMap(); + m.put("role1",new Object[]{new String[]{"ga1","ga2"}, new Object()}); + mapper.setAttributes2grantedAuthoritiesMap(m); + mapper.afterPropertiesSet(); + } + + @Test + public void testAfterPropertiesSetValidMap() throws Exception { + MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); + HashMap m = getValidAttributes2GrantedAuthoritiesMap(); + mapper.setAttributes2grantedAuthoritiesMap(m); + mapper.afterPropertiesSet(); + } + + @Test + public void testMapping1() throws Exception { + String[] roles = { "role1" }; + String[] expectedGas = { "ga1" }; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + @Test + public void testMapping2() throws Exception { + String[] roles = { "role2" }; + String[] expectedGas = { "ga2" }; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + @Test + public void testMapping3() throws Exception { + String[] roles = { "role3" }; + String[] expectedGas = { "ga3", "ga4" }; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + @Test + public void testMapping4() throws Exception { + String[] roles = { "role4" }; + String[] expectedGas = { "ga5", "ga6" }; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + @Test + public void testMapping5() throws Exception { + String[] roles = { "role5" }; + String[] expectedGas = { "ga7", "ga8", "ga9" }; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + @Test + public void testMapping6() throws Exception { + String[] roles = { "role6" }; + String[] expectedGas = { "ga10", "ga11", "ga12" }; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + @Test + public void testMapping7() throws Exception { + String[] roles = { "role7" }; + String[] expectedGas = { "ga13", "ga14" }; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + @Test + public void testMapping8() throws Exception { + String[] roles = { "role8" }; + String[] expectedGas = { "ga13", "ga14" }; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + @Test + public void testMapping9() throws Exception { + String[] roles = { "role9" }; + String[] expectedGas = {}; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + @Test + public void testMapping10() throws Exception { + String[] roles = { "role10" }; + String[] expectedGas = {}; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + @Test + public void testMapping11() throws Exception { + String[] roles = { "role11" }; + String[] expectedGas = {}; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + @Test + public void testNonExistingMapping() throws Exception { + String[] roles = { "nonExisting" }; + String[] expectedGas = {}; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + @Test + public void testMappingCombination() throws Exception { + String[] roles = { "role1", "role2", "role3", "role4", "role5", "role6", "role7", "role8", "role9", "role10", "role11" }; + String[] expectedGas = { "ga1", "ga2", "ga3", "ga4", "ga5", "ga6", "ga7", "ga8", "ga9", "ga10", "ga11", "ga12", "ga13", "ga14"}; + Attributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + private HashMap getValidAttributes2GrantedAuthoritiesMap() { + HashMap m = new HashMap(); + m.put("role1","ga1"); + m.put("role2",new GrantedAuthorityImpl("ga2")); + m.put("role3",Arrays.asList(new Object[]{"ga3",new GrantedAuthorityImpl("ga4")})); + m.put("role4","ga5,ga6"); + m.put("role5",Arrays.asList(new Object[]{"ga7","ga8",new Object[]{new GrantedAuthorityImpl("ga9")}})); + m.put("role6",new Object[]{"ga10","ga11",new Object[]{new GrantedAuthorityImpl("ga12")}}); + m.put("role7",new String[]{"ga13","ga14"}); + m.put("role8",new String[]{"ga13","ga14",null}); + m.put("role9",null); + m.put("role10",new Object[]{}); + m.put("role11",Arrays.asList(new Object[]{null})); + return m; + } + + private MapBasedAttributes2GrantedAuthoritiesMapper getDefaultMapper() throws Exception { + MapBasedAttributes2GrantedAuthoritiesMapper mapper = new MapBasedAttributes2GrantedAuthoritiesMapper(); + mapper.setAttributes2grantedAuthoritiesMap(getValidAttributes2GrantedAuthoritiesMap()); + mapper.afterPropertiesSet(); + return mapper; + } + + private void testGetGrantedAuthorities(Attributes2GrantedAuthoritiesMapper mapper, String[] roles, String[] expectedGas) { + List result = mapper.getGrantedAuthorities(Arrays.asList(roles)); + Collection resultColl = new ArrayList(result.size()); + for (int i = 0; i < result.size(); i++) { + resultColl.add(result.get(i).getAuthority()); + } + Collection expectedColl = Arrays.asList(expectedGas); + assertTrue("Role collections should match; result: " + resultColl + ", expected: " + expectedColl, expectedColl + .containsAll(resultColl) + && resultColl.containsAll(expectedColl)); + } +} diff --git a/core/src/test/java/org/springframework/security/core/authority/mapping/SimpleRoles2GrantedAuthoritiesMapperTests.java b/core/src/test/java/org/springframework/security/core/authority/mapping/SimpleRoles2GrantedAuthoritiesMapperTests.java index a74786af67..fbc7ea211a 100755 --- a/core/src/test/java/org/springframework/security/core/authority/mapping/SimpleRoles2GrantedAuthoritiesMapperTests.java +++ b/core/src/test/java/org/springframework/security/core/authority/mapping/SimpleRoles2GrantedAuthoritiesMapperTests.java @@ -1,123 +1,123 @@ -package org.springframework.security.core.authority.mapping; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.mapping.SimpleAttributes2GrantedAuthoritiesMapper; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import junit.framework.TestCase; - -/** - * - * @author TSARDD - * @since 18-okt-2007 - */ -public class SimpleRoles2GrantedAuthoritiesMapperTests extends TestCase { - - public final void testAfterPropertiesSetConvertToUpperAndLowerCase() { - SimpleAttributes2GrantedAuthoritiesMapper mapper = new SimpleAttributes2GrantedAuthoritiesMapper(); - mapper.setConvertAttributeToLowerCase(true); - mapper.setConvertAttributeToUpperCase(true); - try { - mapper.afterPropertiesSet(); - fail("Expected exception not thrown"); - } catch (IllegalArgumentException expected) { - } catch (Exception unexpected) { - fail("Unexpected exception: " + unexpected); - } - } - - public final void testAfterPropertiesSet() { - SimpleAttributes2GrantedAuthoritiesMapper mapper = new SimpleAttributes2GrantedAuthoritiesMapper(); - try { - mapper.afterPropertiesSet(); - } catch (Exception unexpected) { - fail("Unexpected exception: " + unexpected); - } - } - - public final void testGetGrantedAuthoritiesNoConversion() { - String[] roles = { "Role1", "Role2" }; - String[] expectedGas = { "Role1", "Role2" }; - SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - public final void testGetGrantedAuthoritiesToUpperCase() { - String[] roles = { "Role1", "Role2" }; - String[] expectedGas = { "ROLE1", "ROLE2" }; - SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - mapper.setConvertAttributeToUpperCase(true); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - public final void testGetGrantedAuthoritiesToLowerCase() { - String[] roles = { "Role1", "Role2" }; - String[] expectedGas = { "role1", "role2" }; - SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - mapper.setConvertAttributeToLowerCase(true); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - public final void testGetGrantedAuthoritiesAddPrefixIfAlreadyExisting() { - String[] roles = { "Role1", "Role2", "ROLE_Role3" }; - String[] expectedGas = { "ROLE_Role1", "ROLE_Role2", "ROLE_ROLE_Role3" }; - SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - mapper.setAddPrefixIfAlreadyExisting(true); - mapper.setAttributePrefix("ROLE_"); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - public final void testGetGrantedAuthoritiesDontAddPrefixIfAlreadyExisting1() { - String[] roles = { "Role1", "Role2", "ROLE_Role3" }; - String[] expectedGas = { "ROLE_Role1", "ROLE_Role2", "ROLE_Role3" }; - SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - mapper.setAddPrefixIfAlreadyExisting(false); - mapper.setAttributePrefix("ROLE_"); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - public final void testGetGrantedAuthoritiesDontAddPrefixIfAlreadyExisting2() { - String[] roles = { "Role1", "Role2", "role_Role3" }; - String[] expectedGas = { "ROLE_Role1", "ROLE_Role2", "ROLE_role_Role3" }; - SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - mapper.setAddPrefixIfAlreadyExisting(false); - mapper.setAttributePrefix("ROLE_"); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - public final void testGetGrantedAuthoritiesCombination1() { - String[] roles = { "Role1", "Role2", "role_Role3" }; - String[] expectedGas = { "ROLE_ROLE1", "ROLE_ROLE2", "ROLE_ROLE3" }; - SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); - mapper.setAddPrefixIfAlreadyExisting(false); - mapper.setConvertAttributeToUpperCase(true); - mapper.setAttributePrefix("ROLE_"); - testGetGrantedAuthorities(mapper, roles, expectedGas); - } - - private void testGetGrantedAuthorities(SimpleAttributes2GrantedAuthoritiesMapper mapper, String[] roles, String[] expectedGas) { - List result = mapper.getGrantedAuthorities(Arrays.asList(roles)); - Collection resultColl = new ArrayList(result.size()); - for (int i = 0; i < result.size(); i++) { - resultColl.add(result.get(i).getAuthority()); - } - Collection expectedColl = Arrays.asList(expectedGas); - assertTrue("Role collections do not match; result: " + resultColl + ", expected: " + expectedColl, expectedColl - .containsAll(resultColl) - && resultColl.containsAll(expectedColl)); - } - - private SimpleAttributes2GrantedAuthoritiesMapper getDefaultMapper() { - SimpleAttributes2GrantedAuthoritiesMapper mapper = new SimpleAttributes2GrantedAuthoritiesMapper(); - mapper.setAttributePrefix(""); - mapper.setConvertAttributeToLowerCase(false); - mapper.setConvertAttributeToUpperCase(false); - mapper.setAddPrefixIfAlreadyExisting(false); - return mapper; - } - -} +package org.springframework.security.core.authority.mapping; + +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.mapping.SimpleAttributes2GrantedAuthoritiesMapper; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import junit.framework.TestCase; + +/** + * + * @author TSARDD + * @since 18-okt-2007 + */ +public class SimpleRoles2GrantedAuthoritiesMapperTests extends TestCase { + + public final void testAfterPropertiesSetConvertToUpperAndLowerCase() { + SimpleAttributes2GrantedAuthoritiesMapper mapper = new SimpleAttributes2GrantedAuthoritiesMapper(); + mapper.setConvertAttributeToLowerCase(true); + mapper.setConvertAttributeToUpperCase(true); + try { + mapper.afterPropertiesSet(); + fail("Expected exception not thrown"); + } catch (IllegalArgumentException expected) { + } catch (Exception unexpected) { + fail("Unexpected exception: " + unexpected); + } + } + + public final void testAfterPropertiesSet() { + SimpleAttributes2GrantedAuthoritiesMapper mapper = new SimpleAttributes2GrantedAuthoritiesMapper(); + try { + mapper.afterPropertiesSet(); + } catch (Exception unexpected) { + fail("Unexpected exception: " + unexpected); + } + } + + public final void testGetGrantedAuthoritiesNoConversion() { + String[] roles = { "Role1", "Role2" }; + String[] expectedGas = { "Role1", "Role2" }; + SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + public final void testGetGrantedAuthoritiesToUpperCase() { + String[] roles = { "Role1", "Role2" }; + String[] expectedGas = { "ROLE1", "ROLE2" }; + SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + mapper.setConvertAttributeToUpperCase(true); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + public final void testGetGrantedAuthoritiesToLowerCase() { + String[] roles = { "Role1", "Role2" }; + String[] expectedGas = { "role1", "role2" }; + SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + mapper.setConvertAttributeToLowerCase(true); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + public final void testGetGrantedAuthoritiesAddPrefixIfAlreadyExisting() { + String[] roles = { "Role1", "Role2", "ROLE_Role3" }; + String[] expectedGas = { "ROLE_Role1", "ROLE_Role2", "ROLE_ROLE_Role3" }; + SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + mapper.setAddPrefixIfAlreadyExisting(true); + mapper.setAttributePrefix("ROLE_"); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + public final void testGetGrantedAuthoritiesDontAddPrefixIfAlreadyExisting1() { + String[] roles = { "Role1", "Role2", "ROLE_Role3" }; + String[] expectedGas = { "ROLE_Role1", "ROLE_Role2", "ROLE_Role3" }; + SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + mapper.setAddPrefixIfAlreadyExisting(false); + mapper.setAttributePrefix("ROLE_"); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + public final void testGetGrantedAuthoritiesDontAddPrefixIfAlreadyExisting2() { + String[] roles = { "Role1", "Role2", "role_Role3" }; + String[] expectedGas = { "ROLE_Role1", "ROLE_Role2", "ROLE_role_Role3" }; + SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + mapper.setAddPrefixIfAlreadyExisting(false); + mapper.setAttributePrefix("ROLE_"); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + public final void testGetGrantedAuthoritiesCombination1() { + String[] roles = { "Role1", "Role2", "role_Role3" }; + String[] expectedGas = { "ROLE_ROLE1", "ROLE_ROLE2", "ROLE_ROLE3" }; + SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); + mapper.setAddPrefixIfAlreadyExisting(false); + mapper.setConvertAttributeToUpperCase(true); + mapper.setAttributePrefix("ROLE_"); + testGetGrantedAuthorities(mapper, roles, expectedGas); + } + + private void testGetGrantedAuthorities(SimpleAttributes2GrantedAuthoritiesMapper mapper, String[] roles, String[] expectedGas) { + List result = mapper.getGrantedAuthorities(Arrays.asList(roles)); + Collection resultColl = new ArrayList(result.size()); + for (int i = 0; i < result.size(); i++) { + resultColl.add(result.get(i).getAuthority()); + } + Collection expectedColl = Arrays.asList(expectedGas); + assertTrue("Role collections do not match; result: " + resultColl + ", expected: " + expectedColl, expectedColl + .containsAll(resultColl) + && resultColl.containsAll(expectedColl)); + } + + private SimpleAttributes2GrantedAuthoritiesMapper getDefaultMapper() { + SimpleAttributes2GrantedAuthoritiesMapper mapper = new SimpleAttributes2GrantedAuthoritiesMapper(); + mapper.setAttributePrefix(""); + mapper.setConvertAttributeToLowerCase(false); + mapper.setConvertAttributeToUpperCase(false); + mapper.setAddPrefixIfAlreadyExisting(false); + return mapper; + } + +} diff --git a/core/src/test/java/org/springframework/security/core/context/SecurityContextHolderTests.java b/core/src/test/java/org/springframework/security/core/context/SecurityContextHolderTests.java index 2f65bad80c..6e46b385d6 100644 --- a/core/src/test/java/org/springframework/security/core/context/SecurityContextHolderTests.java +++ b/core/src/test/java/org/springframework/security/core/context/SecurityContextHolderTests.java @@ -24,7 +24,6 @@ import org.springframework.security.core.context.SecurityContextImpl; * Tests {@link SecurityContextHolder}. * * @author Ben Alex - * @version $Id$ */ public class SecurityContextHolderTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/core/context/SecurityContextImplTests.java b/core/src/test/java/org/springframework/security/core/context/SecurityContextImplTests.java index 21a4ae8082..3659bac10d 100644 --- a/core/src/test/java/org/springframework/security/core/context/SecurityContextImplTests.java +++ b/core/src/test/java/org/springframework/security/core/context/SecurityContextImplTests.java @@ -27,7 +27,6 @@ import org.springframework.security.core.context.SecurityContextImpl; * Tests {@link SecurityContextImpl}. * * @author Ben Alex - * @version $Id$ */ public class SecurityContextImplTests extends TestCase { //~ Constructors =================================================================================================== diff --git a/core/src/test/java/org/springframework/security/core/session/SessionInformationTests.java b/core/src/test/java/org/springframework/security/core/session/SessionInformationTests.java index d053423e5d..949dcc64cb 100644 --- a/core/src/test/java/org/springframework/security/core/session/SessionInformationTests.java +++ b/core/src/test/java/org/springframework/security/core/session/SessionInformationTests.java @@ -26,7 +26,6 @@ import org.springframework.security.core.session.SessionInformation; * Tests {@link SessionInformation}. * * @author Ben Alex - * @version $Id$ */ public class SessionInformationTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/core/src/test/java/org/springframework/security/core/session/SessionRegistryImplTests.java b/core/src/test/java/org/springframework/security/core/session/SessionRegistryImplTests.java index 6b2fcbecc3..28c7c5ce48 100644 --- a/core/src/test/java/org/springframework/security/core/session/SessionRegistryImplTests.java +++ b/core/src/test/java/org/springframework/security/core/session/SessionRegistryImplTests.java @@ -31,7 +31,6 @@ import org.springframework.security.core.session.SessionRegistryImpl; * Tests {@link SessionRegistryImpl}. * * @author Ben Alex - * @version $Id$ */ public class SessionRegistryImplTests { private SessionRegistryImpl sessionRegistry; diff --git a/core/src/test/java/org/springframework/security/core/token/DefaultTokenTests.java b/core/src/test/java/org/springframework/security/core/token/DefaultTokenTests.java index 7514808d66..487e45e088 100644 --- a/core/src/test/java/org/springframework/security/core/token/DefaultTokenTests.java +++ b/core/src/test/java/org/springframework/security/core/token/DefaultTokenTests.java @@ -9,7 +9,7 @@ import org.springframework.security.core.token.DefaultToken; /** * Tests {@link DefaultToken}. - * + * * @author Ben Alex * */ @@ -19,12 +19,12 @@ public class DefaultTokenTests { String key = "key"; long created = new Date().getTime(); String extendedInformation = "extended"; - + DefaultToken t1 = new DefaultToken(key, created, extendedInformation); DefaultToken t2 = new DefaultToken(key, created, extendedInformation); Assert.assertEquals(t1, t2); } - + @Test(expected=IllegalArgumentException.class) public void testRejectsNullExtendedInformation() { String key = "key"; @@ -36,7 +36,7 @@ public class DefaultTokenTests { public void testEqualityWithDifferentExtendedInformation3() { String key = "key"; long created = new Date().getTime(); - + DefaultToken t1 = new DefaultToken(key, created, "length1"); DefaultToken t2 = new DefaultToken(key, created, "longerLength2"); Assert.assertFalse(t1.equals(t2)); diff --git a/core/src/test/java/org/springframework/security/core/token/KeyBasedPersistenceTokenServiceTests.java b/core/src/test/java/org/springframework/security/core/token/KeyBasedPersistenceTokenServiceTests.java index eaa2de0d14..ae3580dc1d 100644 --- a/core/src/test/java/org/springframework/security/core/token/KeyBasedPersistenceTokenServiceTests.java +++ b/core/src/test/java/org/springframework/security/core/token/KeyBasedPersistenceTokenServiceTests.java @@ -15,7 +15,7 @@ import org.springframework.security.core.token.Token; /** * Tests {@link KeyBasedPersistenceTokenService}. - * + * * @author Ben Alex * */ @@ -35,7 +35,7 @@ public class KeyBasedPersistenceTokenServiceTests { } return service; } - + @Test public void testOperationWithSimpleExtendedInformation() { KeyBasedPersistenceTokenService service = getService(); @@ -61,7 +61,7 @@ public class KeyBasedPersistenceTokenServiceTests { Token result = service.verifyToken(token.getKey()); Assert.assertEquals(token, result); } - + @Test public void testOperationWithNoExtendedInformation() { KeyBasedPersistenceTokenService service = getService(); @@ -69,14 +69,14 @@ public class KeyBasedPersistenceTokenServiceTests { Token result = service.verifyToken(token.getKey()); Assert.assertEquals(token, result); } - + @Test(expected=IllegalArgumentException.class) public void testOperationWithMissingKey() { KeyBasedPersistenceTokenService service = getService(); Token token = new DefaultToken("", new Date().getTime(), ""); service.verifyToken(token.getKey()); } - + @Test(expected=IllegalArgumentException.class) public void testOperationWithTamperedKey() { KeyBasedPersistenceTokenService service = getService(); diff --git a/core/src/test/java/org/springframework/security/core/userdetails/MockUserDetailsService.java b/core/src/test/java/org/springframework/security/core/userdetails/MockUserDetailsService.java index 18f67d685f..3cacf102b3 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/MockUserDetailsService.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/MockUserDetailsService.java @@ -17,7 +17,6 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException; * valid, locked, disabled, credentialsExpired, expired. All passwords are "". * * @author Luke Taylor - * @version $Id$ */ public class MockUserDetailsService implements UserDetailsService { private Map users = new HashMap(); diff --git a/core/src/test/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapperTests.java b/core/src/test/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapperTests.java index 08b4afaf20..8f0f7b072c 100755 --- a/core/src/test/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapperTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapperTests.java @@ -1,51 +1,51 @@ -package org.springframework.security.core.userdetails; - -import junit.framework.TestCase; - -import org.springframework.dao.DataAccessException; -import org.springframework.security.authentication.TestingAuthenticationToken; -import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -/** - * - * @author TSARDD - * @since 18-okt-2007 - */ -public class UserDetailsByNameServiceWrapperTests extends TestCase { - - public final void testAfterPropertiesSet() { - UserDetailsByNameServiceWrapper svc = new UserDetailsByNameServiceWrapper(); - try { - svc.afterPropertiesSet(); - fail("AfterPropertiesSet didn't throw expected exception"); - } catch (IllegalArgumentException expected) { - } catch (Exception unexpected) { - fail("AfterPropertiesSet throws unexpected exception"); - } - } - - public final void testGetUserDetails() throws Exception { - UserDetailsByNameServiceWrapper svc = new UserDetailsByNameServiceWrapper(); - final User user = new User("dummy", "dummy", true, true, true, true, AuthorityUtils.NO_AUTHORITIES); - svc.setUserDetailsService(new UserDetailsService() { - public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException, DataAccessException { - if (user != null && user.getUsername().equals(name)) { - return user; - } else { - return null; - } - } - }); - svc.afterPropertiesSet(); - UserDetails result1 = svc.loadUserDetails(new TestingAuthenticationToken("dummy", "dummy")); - assertEquals("Result doesn't match original user", user, result1); - UserDetails result2 = svc.loadUserDetails(new TestingAuthenticationToken("dummy2", "dummy")); - assertNull("Result should have been null", result2); - } - -} +package org.springframework.security.core.userdetails; + +import junit.framework.TestCase; + +import org.springframework.dao.DataAccessException; +import org.springframework.security.authentication.TestingAuthenticationToken; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; + +/** + * + * @author TSARDD + * @since 18-okt-2007 + */ +public class UserDetailsByNameServiceWrapperTests extends TestCase { + + public final void testAfterPropertiesSet() { + UserDetailsByNameServiceWrapper svc = new UserDetailsByNameServiceWrapper(); + try { + svc.afterPropertiesSet(); + fail("AfterPropertiesSet didn't throw expected exception"); + } catch (IllegalArgumentException expected) { + } catch (Exception unexpected) { + fail("AfterPropertiesSet throws unexpected exception"); + } + } + + public final void testGetUserDetails() throws Exception { + UserDetailsByNameServiceWrapper svc = new UserDetailsByNameServiceWrapper(); + final User user = new User("dummy", "dummy", true, true, true, true, AuthorityUtils.NO_AUTHORITIES); + svc.setUserDetailsService(new UserDetailsService() { + public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException, DataAccessException { + if (user != null && user.getUsername().equals(name)) { + return user; + } else { + return null; + } + } + }); + svc.afterPropertiesSet(); + UserDetails result1 = svc.loadUserDetails(new TestingAuthenticationToken("dummy", "dummy")); + assertEquals("Result doesn't match original user", user, result1); + UserDetails result2 = svc.loadUserDetails(new TestingAuthenticationToken("dummy2", "dummy")); + assertNull("Result should have been null", result2); + } + +} diff --git a/core/src/test/java/org/springframework/security/core/userdetails/UserTests.java b/core/src/test/java/org/springframework/security/core/userdetails/UserTests.java index 013faa372d..e1621f6645 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/UserTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/UserTests.java @@ -31,7 +31,6 @@ import org.springframework.security.core.authority.GrantedAuthorityImpl; * Tests {@link User}. * * @author Ben Alex - * @version $Id$ */ public class UserTests { private static final List ROLE_12 = AuthorityUtils.createAuthorityList("ROLE_ONE","ROLE_TWO"); diff --git a/core/src/test/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCacheTests.java b/core/src/test/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCacheTests.java index ff22b551f7..8888dd4e95 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCacheTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCacheTests.java @@ -32,7 +32,6 @@ import org.springframework.security.core.userdetails.cache.EhCacheBasedUserCache * Tests {@link EhCacheBasedUserCache}. * * @author Ben Alex - * @version $Id$ */ public class EhCacheBasedUserCacheTests { private static CacheManager cacheManager; diff --git a/core/src/test/java/org/springframework/security/core/userdetails/cache/NullUserCacheTests.java b/core/src/test/java/org/springframework/security/core/userdetails/cache/NullUserCacheTests.java index 870d0893ac..cf48be34cd 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/cache/NullUserCacheTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/cache/NullUserCacheTests.java @@ -26,7 +26,6 @@ import org.springframework.security.core.userdetails.cache.NullUserCache; * Tests {@link NullUserCache}. * * @author Ben Alex - * @version $Id$ */ public class NullUserCacheTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImplTests.java b/core/src/test/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImplTests.java index 696f00fec0..6d3fabaae2 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImplTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImplTests.java @@ -27,7 +27,6 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException; * Tests {@link JdbcDaoImpl}. * * @author Ben Alex - * @version $Id$ */ public class JdbcDaoImplTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/core/userdetails/memory/InMemoryDaoTests.java b/core/src/test/java/org/springframework/security/core/userdetails/memory/InMemoryDaoTests.java index e4bc8abb1c..e0b21c625e 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/memory/InMemoryDaoTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/memory/InMemoryDaoTests.java @@ -29,7 +29,6 @@ import java.util.Properties; * Tests {@link InMemoryDaoImpl}. * * @author Ben Alex - * @version $Id$ */ public class InMemoryDaoTests extends TestCase { //~ Constructors =================================================================================================== diff --git a/core/src/test/java/org/springframework/security/core/userdetails/memory/UserAttributeEditorTests.java b/core/src/test/java/org/springframework/security/core/userdetails/memory/UserAttributeEditorTests.java index 23abbbe456..1ee87b87d9 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/memory/UserAttributeEditorTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/memory/UserAttributeEditorTests.java @@ -25,7 +25,6 @@ import org.springframework.security.core.userdetails.memory.UserAttributeEditor; * Tests {@link UserAttributeEditor} and associated {@link UserAttribute}. * * @author Ben Alex - * @version $Id$ */ public class UserAttributeEditorTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/core/userdetails/memory/UserMapEditorTests.java b/core/src/test/java/org/springframework/security/core/userdetails/memory/UserMapEditorTests.java index 0f62884a1c..114a3a267b 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/memory/UserMapEditorTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/memory/UserMapEditorTests.java @@ -26,7 +26,6 @@ import org.springframework.security.core.userdetails.memory.UserMapEditor; * Tests {@link UserMapEditor}. * * @author Ben Alex - * @version $Id$ */ public class UserMapEditorTests extends TestCase { //~ Constructors =================================================================================================== diff --git a/core/src/test/java/org/springframework/security/core/userdetails/memory/UserMapTests.java b/core/src/test/java/org/springframework/security/core/userdetails/memory/UserMapTests.java index 4043961496..08213b761e 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/memory/UserMapTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/memory/UserMapTests.java @@ -28,7 +28,6 @@ import org.springframework.security.core.userdetails.memory.UserMap; * Tests {@link UserMap}. * * @author Ben Alex - * @version $Id$ */ public class UserMapTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/provisioning/JdbcUserDetailsManagerTests.java b/core/src/test/java/org/springframework/security/provisioning/JdbcUserDetailsManagerTests.java index 7d1d3dd265..776aae3853 100644 --- a/core/src/test/java/org/springframework/security/provisioning/JdbcUserDetailsManagerTests.java +++ b/core/src/test/java/org/springframework/security/provisioning/JdbcUserDetailsManagerTests.java @@ -32,7 +32,6 @@ import org.springframework.security.core.userdetails.UserDetails; * Tests for {@link JdbcUserDetailsManager} * * @author Luke Taylor - * @version $Id$ */ public class JdbcUserDetailsManagerTests { private static final String SELECT_JOE_SQL = "select * from users where username = 'joe'"; diff --git a/core/src/test/java/org/springframework/security/remoting/dns/JndiDnsResolverTest.java b/core/src/test/java/org/springframework/security/remoting/dns/JndiDnsResolverTest.java index bd753f80ca..679f838006 100644 --- a/core/src/test/java/org/springframework/security/remoting/dns/JndiDnsResolverTest.java +++ b/core/src/test/java/org/springframework/security/remoting/dns/JndiDnsResolverTest.java @@ -33,7 +33,6 @@ import org.junit.Test; * * @author Mike Wiesner * @since 3.0 - * @version $Id$ */ public class JndiDnsResolverTest { diff --git a/core/src/test/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutorTests.java b/core/src/test/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutorTests.java index e5b898162c..d32d1665d5 100644 --- a/core/src/test/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutorTests.java +++ b/core/src/test/java/org/springframework/security/remoting/httpinvoker/AuthenticationSimpleHttpInvokerRequestExecutorTests.java @@ -37,7 +37,6 @@ import java.util.Map; * Tests {@link AuthenticationSimpleHttpInvokerRequestExecutor}. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationSimpleHttpInvokerRequestExecutorTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocationTests.java b/core/src/test/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocationTests.java index ebb0b543a0..33c3ec8e02 100644 --- a/core/src/test/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocationTests.java +++ b/core/src/test/java/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocationTests.java @@ -37,7 +37,6 @@ import java.lang.reflect.Method; * Tests {@link ContextPropagatingRemoteInvocation} and {@link ContextPropagatingRemoteInvocationFactory}. * * @author Ben Alex - * @version $Id$ */ public class ContextPropagatingRemoteInvocationTests extends TestCase { diff --git a/core/src/test/java/org/springframework/security/util/EncryptionUtilsTests.java b/core/src/test/java/org/springframework/security/util/EncryptionUtilsTests.java index 4c0b2a4359..310bec979e 100644 --- a/core/src/test/java/org/springframework/security/util/EncryptionUtilsTests.java +++ b/core/src/test/java/org/springframework/security/util/EncryptionUtilsTests.java @@ -24,7 +24,6 @@ import org.springframework.security.util.EncryptionUtils.EncryptionException; * * @author Alan Stewart * @author Ben Alex - * @version $Id$ */ public class EncryptionUtilsTests extends TestCase { private final static String STRING_TO_ENCRYPT = "Alan K Stewart"; diff --git a/core/src/test/java/org/springframework/security/util/MethodInvocationUtilsTests.java b/core/src/test/java/org/springframework/security/util/MethodInvocationUtilsTests.java index e7ca4b29f2..4fdee220bc 100644 --- a/core/src/test/java/org/springframework/security/util/MethodInvocationUtilsTests.java +++ b/core/src/test/java/org/springframework/security/util/MethodInvocationUtilsTests.java @@ -9,7 +9,6 @@ import org.springframework.security.access.annotation.BusinessServiceImpl; /** * * @author Luke Taylor - * @version $Id$ */ public class MethodInvocationUtilsTests { diff --git a/core/src/test/resources/log4j.properties b/core/src/test/resources/log4j.properties index 1105fbba99..28af98e0e9 100644 --- a/core/src/test/resources/log4j.properties +++ b/core/src/test/resources/log4j.properties @@ -1,6 +1,5 @@ # Logging # -# $Id$ log4j.rootLogger=INFO, stdout diff --git a/core/src/test/resources/org/springframework/security/authentication/jaas/JaasAuthenticationProviderTests.xml b/core/src/test/resources/org/springframework/security/authentication/jaas/JaasAuthenticationProviderTests.xml index c8b2dc3fd7..354b5e912c 100644 --- a/core/src/test/resources/org/springframework/security/authentication/jaas/JaasAuthenticationProviderTests.xml +++ b/core/src/test/resources/org/springframework/security/authentication/jaas/JaasAuthenticationProviderTests.xml @@ -1,7 +1,6 @@ - diff --git a/docs/faq/src/docbook/faq.xml b/docs/faq/src/docbook/faq.xml index 8f0f092792..1ca985d076 100644 --- a/docs/faq/src/docbook/faq.xml +++ b/docs/faq/src/docbook/faq.xml @@ -167,7 +167,7 @@ DEBUG [ExceptionTranslationFilter] - Access is denied (user is anonymous); redirecting to authentication entry point org.springframework.security.AccessDeniedException: Access is denied at org.springframework.security.vote.AffirmativeBased.decide(AffirmativeBased.java:68) - at org.springframework.security.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:262) + at org.springframework.security.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:262) It is normal and shouldn't be anything to worry about. @@ -225,10 +225,10 @@ Make sure you have added the listener to your web.xml file. It is essential to make sure that the Spring Security session registry is notified when a session is destroyed. Without it, the session information will not be - removed from the registry. org.springframework.security.ui.session.HttpSessionEventPublisher - ]]> + ]]> @@ -288,20 +288,20 @@ Spring Security has a voter-based architecture which means that an access decision is made by a series of AccessDecisionVoters. - The voters act on the configuration attributes which are specified for a + The voters act on the configuration attributes which are specified for a secured resource (such as a method invocation). With this approach, not all attributes may be relevant to all voters and a voter needs to know when it should ignore an attribute (abstain) and - when it should vote to grant or deny access based on the attribute value. + when it should vote to grant or deny access based on the attribute value. The most common voter is the RoleVoter which by default votes whenever it finds an attribute with the ROLE_ prefix. It makes a simple comparison of the attribute (such as ROLE_USER) with the name names of the authorities which - the current user has been assigned. If it finds a match (they have an authority called - ROLE_USER), it votes to grant access, otherwise it votes to deny access. + the current user has been assigned. If it finds a match (they have an authority called + ROLE_USER), it votes to grant access, otherwise it votes to deny access. - The prefix can be changed by setting the rolePrefix property of + The prefix can be changed by setting the rolePrefix property of RoleVoter. If you only need to use roles in your application and have - no need for other custom voters, then you can set the prefix to a blank string, in which case the + no need for other custom voters, then you can set the prefix to a blank string, in which case the RoleVoter will treat all attributes as roles. @@ -379,26 +379,26 @@ contain.. A very basic outline would look something like this: getAttributes(Object object) { - FilterInvocation fi = (FilterInvocation) object; + FilterInvocation fi = (FilterInvocation) object; String url = fi.getRequestUrl(); String httpMethod = fi.getRequest().getMethod(); List attributes = new ArrayList(); // Lookup your database (or other source) using this information and populate the // list of attributes - + return attributes; - } + } public Collection getAllConfigAttributes() { return null; } - + public boolean supports(Class clazz) { return FilterInvocation.class.isAssignableFrom(clazz); - } + } } ]]> For more information, look at the code for DefaultFilterInvocationSecurityMetadataSource. @@ -445,13 +445,13 @@ public class MyAuthoritiesPopulator implements LdapAuthoritiesPopulator { @Autowired JdbcTemplate template; - + List getGrantedAuthorities(DirContextOperations userData, String username) { List = template.query("select role from roles where username = ?", new String[] {username}, new RowMapper() { - /** - * We're assuming here that you're using the standard convention of using the role + /** + * We're assuming here that you're using the standard convention of using the role * prefix "ROLE_" to mark attributes which are supported by Spring Security's RoleVoter. - */ + */ public GrantedAuthority mapRow(ResultSet rs, int rowNum) throws SQLException { return new GrantedAuthorityImpl("ROLE_" + rs.getString(1); } diff --git a/docs/manual/src/docbook/appendix-db-schema.xml b/docs/manual/src/docbook/appendix-db-schema.xml index 7b440dc696..d66af274d1 100644 --- a/docs/manual/src/docbook/appendix-db-schema.xml +++ b/docs/manual/src/docbook/appendix-db-schema.xml @@ -32,18 +32,18 @@ JdbcDaoImpl. The table structure if groups are enabled is as follows: create table groups ( - id bigint generated by default as identity(start with 0) primary key, + id bigint generated by default as identity(start with 0) primary key, group_name varchar_ignorecase(50) not null); create table group_authorities ( - group_id bigint not null, - authority varchar(50) not null, + group_id bigint not null, + authority varchar(50) not null, constraint fk_group_authorities_group foreign key(group_id) references groups(id)); create table group_members ( - id bigint generated by default as identity(start with 0) primary key, - username varchar(50) not null, - group_id bigint not null, + id bigint generated by default as identity(start with 0) primary key, + username varchar(50) not null, + group_id bigint not null, constraint fk_group_members_group foreign key(group_id) references groups(id)); @@ -56,9 +56,9 @@ create table group_members ( directly or through the namespace, then you will need this table. create table persistent_logins ( - username varchar(64) not null, + username varchar(64) not null, series varchar(64) primary key, - token varchar(64) not null, + token varchar(64) not null, last_used timestamp not null); @@ -94,7 +94,7 @@ create table persistent_logins ( Hypersonic SQL The default schema works with the embedded HSQLDB database that is used in unit tests within the - framework. + framework. create table acl_sid ( id bigint generated by default as identity(start with 100) not null primary key, principal boolean not null, @@ -102,30 +102,30 @@ create table acl_sid ( constraint unique_uk_1 unique(sid,principal) ); create table acl_class ( - id bigint generated by default as identity(start with 100) not null primary key, - class varchar_ignorecase(100) not null, + id bigint generated by default as identity(start with 100) not null primary key, + class varchar_ignorecase(100) not null, constraint unique_uk_2 unique(class) ); create table acl_object_identity ( - id bigint generated by default as identity(start with 100) not null primary key, - object_id_class bigint not null, - object_id_identity bigint not null, - parent_object bigint, - owner_sid bigint not null, - entries_inheriting boolean not null, - constraint unique_uk_3 unique(object_id_class,object_id_identity), - constraint foreign_fk_1 foreign key(parent_object)references acl_object_identity(id), - constraint foreign_fk_2 foreign key(object_id_class)references acl_class(id), + id bigint generated by default as identity(start with 100) not null primary key, + object_id_class bigint not null, + object_id_identity bigint not null, + parent_object bigint, + owner_sid bigint not null, + entries_inheriting boolean not null, + constraint unique_uk_3 unique(object_id_class,object_id_identity), + constraint foreign_fk_1 foreign key(parent_object)references acl_object_identity(id), + constraint foreign_fk_2 foreign key(object_id_class)references acl_class(id), constraint foreign_fk_3 foreign key(owner_sid)references acl_sid(id) ); -create table acl_entry ( - id bigint generated by default as identity(start with 100) not null primary key, - acl_object_identity bigint not null,ace_order int not null,sid bigint not null, - mask integer not null,granting boolean not null,audit_success boolean not null, +create table acl_entry ( + id bigint generated by default as identity(start with 100) not null primary key, + acl_object_identity bigint not null,ace_order int not null,sid bigint not null, + mask integer not null,granting boolean not null,audit_success boolean not null, audit_failure boolean not null, - constraint unique_uk_4 unique(acl_object_identity,ace_order), - constraint foreign_fk_4 foreign key(acl_object_identity) - references acl_object_identity(id), + constraint unique_uk_4 unique(acl_object_identity,ace_order), + constraint foreign_fk_4 foreign key(acl_object_identity) + references acl_object_identity(id), constraint foreign_fk_5 foreign key(sid) references acl_sid(id) ); @@ -165,7 +165,7 @@ create table acl_entry( audit_success boolean not null, audit_failure boolean not null, constraint unique_uk_4 unique(acl_object_identity,ace_order), - constraint foreign_fk_4 foreign key(acl_object_identity) + constraint foreign_fk_4 foreign key(acl_object_identity) references acl_object_identity(id), constraint foreign_fk_5 foreign key(sid) references acl_sid(id)); diff --git a/docs/manual/src/docbook/authorization-common.xml b/docs/manual/src/docbook/authorization-common.xml index 63c99473b7..2b6cafb2aa 100644 --- a/docs/manual/src/docbook/authorization-common.xml +++ b/docs/manual/src/docbook/authorization-common.xml @@ -60,7 +60,7 @@ access control decisions. The AccessDecisionManager interface contains three methods: - void decide(Authentication authentication, Object secureObject, + void decide(Authentication authentication, Object secureObject, List<ConfigAttribute> config) throws AccessDeniedException; boolean supports(ConfigAttribute attribute); boolean supports(Class clazz); @@ -93,7 +93,7 @@
Voting Decision Manager - - -
diff --git a/docs/manual/src/docbook/core-filters.xml b/docs/manual/src/docbook/core-filters.xml index 5dd7a4b4ae..7c6060fb3f 100644 --- a/docs/manual/src/docbook/core-filters.xml +++ b/docs/manual/src/docbook/core-filters.xml @@ -111,7 +111,7 @@ - + @@ -196,8 +196,8 @@ class="org.springframework.security.web.context.SecurityContextPersistenceFilter public interface SecurityContextRepository { SecurityContext loadContext(HttpRequestResponseHolder requestResponseHolder); - void saveContext(SecurityContext context, HttpServletRequest request, - HttpServletResponse response); + void saveContext(SecurityContext context, HttpServletRequest request, + HttpServletResponse response); } The HttpRequestResponseHolder is simply a container for the @@ -268,12 +268,12 @@ class="org.springframework.security.web.context.SecurityContextPersistenceFilter The login form simply contains j_username and j_password input fields, and posts to the URL that is monitored by the filter (by default this is /j_spring_security_check). The - basic filter configuration looks something like this: - ]]> + ]]>
Application Flow on Authentication Success and Failure diff --git a/docs/manual/src/docbook/dao-auth-provider.xml b/docs/manual/src/docbook/dao-auth-provider.xml index f8cd3a9737..775e2457e3 100644 --- a/docs/manual/src/docbook/dao-auth-provider.xml +++ b/docs/manual/src/docbook/dao-auth-provider.xml @@ -35,7 +35,7 @@ - ]]> + ]]> The PasswordEncoder and SaltSource are optional. @@ -68,20 +68,20 @@ - + - + - -]]> +]]> All Spring Security EH-CACHE implementations (including diff --git a/docs/manual/src/docbook/el-access.xml b/docs/manual/src/docbook/el-access.xml index 258a8930ec..e1dda5458a 100644 --- a/docs/manual/src/docbook/el-access.xml +++ b/docs/manual/src/docbook/el-access.xml @@ -96,7 +96,7 @@ elements to contain Spring EL expressions. The expressions should evaluate to a boolean, defining whether access should be allowed or not. For example: - ... @@ -224,7 +224,7 @@ - ]]>Where myPermissionEvaluator is the bean which diff --git a/docs/manual/src/docbook/form-authentication.xml b/docs/manual/src/docbook/form-authentication.xml index fbd5aa133d..a0d075c23f 100644 --- a/docs/manual/src/docbook/form-authentication.xml +++ b/docs/manual/src/docbook/form-authentication.xml @@ -1,9 +1,9 @@ Form Authentication Mechanism - +
Overview - + HTTP Form Authentication involves using the UsernamePasswordAuthenticationFilter to process a login form. This is the most common way for an application to authenticate end @@ -13,40 +13,40 @@ and it's recommended that you use that unless you have specific customization requirements.
- +
Configuration - + The login form simply contains j_username and j_password input fields, and posts to a URL that is monitored by the filter (by default - /j_spring_security_check). You should add an + /j_spring_security_check). You should add an UsernamePasswordAuthenticationFilter to your application context: - - ]]> + ]]> The configured AuthenticationManager processes each authentication request. The destination following a successful authentication or an authentication failure is controlled by the AuthenticationSuccessHandler and AuthenticationFailureHandler interfaces, respectively. - The filter has properties which allow you to set these + The filter has properties which allow you to set these In versions prior to 3.0, the application flow at this point had evolved to a stage was controlled by a mix of properties on this class and strategy plugins. The decision was made for 3.0 to refactor the code to make these two strategies entirely responsible. . Some standard implementations are supplied for these such as SimpleUrlAuthenticationSuccessHandler, - SavedRequestAwareAuthenticationSuccessHandler, - SimpleUrlAuthenticationFailureHandler and + SavedRequestAwareAuthenticationSuccessHandler, + SimpleUrlAuthenticationFailureHandler and ExceptionMappingAuthenticationFailureHandler. Have a look at the Javadoc - for these classes to see how they work. + for these classes to see how they work. - + If authentication is successful, the resulting Authentication object will be placed into the SecurityContextHolder. @@ -58,7 +58,7 @@ The ExceptionTranslationFilter caches the original request a user makes. When the user authenticates, the request handler makes use of this cached request to obtain the original - URL and redirect to it. The original request is then rebuilt and used as an alternative. + URL and redirect to it. The original request is then rebuilt and used as an alternative. If authentication fails, the configured AuthenticationFailureHandler will be invoked. diff --git a/docs/manual/src/docbook/html-titlepage.xml b/docs/manual/src/docbook/html-titlepage.xml index 99c25da7c4..ee79a7d1a9 100644 --- a/docs/manual/src/docbook/html-titlepage.xml +++ b/docs/manual/src/docbook/html-titlepage.xml @@ -44,7 +44,7 @@ - + diff --git a/docs/manual/src/docbook/jaas-auth-provider.xml b/docs/manual/src/docbook/jaas-auth-provider.xml index 6ac29162a8..1874d6f362 100644 --- a/docs/manual/src/docbook/jaas-auth-provider.xml +++ b/docs/manual/src/docbook/jaas-auth-provider.xml @@ -6,26 +6,26 @@ Spring Security provides a package able to delegate authentication requests to the Java Authentication and Authorization Service (JAAS). This package is discussed in detail below. - + Central to JAAS operation are login configuration files. To learn more about JAAS login configuration files, consult the JAAS reference documentation available from Sun Microsystems. We expect you to have a basic understanding of JAAS and its login configuration file syntax in order to understand this section.
- +
Configuration The JaasAuthenticationProvider attempts to authenticate a user’s principal and credentials through JAAS. - + Let’s assume we have a JAAS login configuration file, /WEB-INF/login.conf, with the following contents: JAASTest { sample.SampleLoginModule required; -}; +}; Like all Spring Security beans, the JaasAuthenticationProvider is configured via the application context. The following definitions would correspond to the @@ -37,9 +37,9 @@ JAASTest { - - @@ -48,19 +48,19 @@ JAASTest { - + ]]> - + The CallbackHandlers and AuthorityGranters are discussed below. - +
JAAS CallbackHandler - + Most JAAS LoginModules require a callback of some sort. These callbacks are usually used to obtain the username and password from the user. - + In a Spring Security deployment, Spring Security is responsible for this user interaction (via the authentication mechanism). Thus, by the time the authentication request is @@ -69,7 +69,7 @@ JAASTest { Authentication object containing all the information required by the JAAS LoginModule. - + Therefore, the JAAS package for Spring Security provides two default callback handlers, JaasNameCallbackHandler and @@ -78,7 +78,7 @@ JAASTest { JaasAuthenticationCallbackHandler. In most cases these callback handlers can simply be used without understanding the internal mechanics. - + For those needing full control over the callback behavior, internally JaasAuthenticationProvider wraps these JaasAuthenticationCallbackHandlers with an @@ -93,10 +93,10 @@ JAASTest { passed to the JaasAuthenticationCallbackHandlers being wrapped.
- +
JAAS AuthorityGranter - + JAAS works with principals. Even "roles" are represented as principals in JAAS. Spring Security, on the other hand, works with Authentication objects. Each @@ -105,10 +105,10 @@ JAASTest { facilitate mapping between these different concepts, Spring Security's JAAS package includes an AuthorityGranter interface. - + An AuthorityGranter is responsible for - inspecting a JAAS principal and returning a set of - Strings, representing the authorities assigned to the principal. + inspecting a JAAS principal and returning a set of + Strings, representing the authorities assigned to the principal. For each returned authority string, the JaasAuthenticationProvider creates a JaasGrantedAuthority (which implements Spring @@ -124,7 +124,7 @@ JAASTest { AuthorityGranter defined against the JaasAuthenticationProvider.setAuthorityGranters(List) property. - + Spring Security does not include any production AuthorityGranters given that every JAAS principal has an implementation-specific meaning. However, there is a diff --git a/docs/manual/src/docbook/ldap-auth-provider.xml b/docs/manual/src/docbook/ldap-auth-provider.xml index 2800cd1fd1..dd0d7e690b 100644 --- a/docs/manual/src/docbook/ldap-auth-provider.xml +++ b/docs/manual/src/docbook/ldap-auth-provider.xml @@ -60,7 +60,7 @@ from the security namespace. This can be configured to point at an external LDAP server, using the url attribute: -]]> +]]>
@@ -70,7 +70,7 @@ embedded server, which can be very useful for testing and demonstrations. In this case you use it without the url attribute: - ]]> + ]]> Here we've specified that the root DIT of the directory should be dc=springframework,dc=org, which is the default. Used this way, the namespace parser will create an embedded Apache Directory server and scan the @@ -96,7 +96,7 @@ that user with the login password. This is OK if all your users are stored under a single node in the directory. If instead you wished to configure an LDAP search filter to locate the user, you could use the following: ]]> If used with the server definition above, this would perform a search under the DN ou=people,dc=springframework,dc=org @@ -134,7 +134,7 @@ on the login name. So if we used the following configuration ]]> and authenticated successfully as user ben, the subsequent loading of authorities would perform a search under the directory entry @@ -314,7 +314,7 @@ - @@ -338,7 +338,7 @@ - ]]> + ]]> and use it by setting the BindAuthenticator bean's userSearch property. The authenticator would then call the search object to obtain the correct @@ -359,11 +359,11 @@ provider's UserDetailsContextMapper strategy, which is responsible for mapping user objects to and from LDAP context data: authorities); void mapUserToContext(UserDetails user, DirContextAdapter ctx); -}]]> +}]]> Only the first method is relevant for authentication. If you provide an implementation of this interface, you can control exactly how the UserDetails object is created. The first parameter is an instance of diff --git a/docs/manual/src/docbook/namespace-config.xml b/docs/manual/src/docbook/namespace-config.xml index daa4278802..43a62e69da 100644 --- a/docs/manual/src/docbook/namespace-config.xml +++ b/docs/manual/src/docbook/namespace-config.xml @@ -16,7 +16,7 @@ complexity from the user. A simple element may conceal the fact that multiple beans and processing steps are being added to the application context. For example, adding the following element from the security namespace to an application context will start up an embedded LDAP - server for testing use within the application: ]]> This is much simpler than wiring up the equivalent Apache Directory Server beans. The most common alternative configuration requirements are supported by attributes on @@ -34,10 +34,10 @@ + http://www.springframework.org/schema/security + http://www.springframework.org/schema/security/spring-security-3.0.xsd"> ... ]]> In many of the examples you will see (and in the sample) applications, we @@ -49,10 +49,10 @@ + http://www.springframework.org/schema/security + http://www.springframework.org/schema/security/spring-security-3.0.xsd"> ... ]]> We'll assume this syntax is being used from now on in this chapter. @@ -101,11 +101,11 @@ springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy - + springSecurityFilterChain /* -]]> +]]> This provides a hook into the Spring Security web infrastructure. DelegatingFilterProxy is a Spring Framework class which delegates to a filter implementation which is defined as a Spring bean in your @@ -224,7 +224,7 @@ customize these options. For example, if you want to supply your own login page, you could use: - + @@ -243,8 +243,8 @@ It is also possible to have all requests matching a particular pattern bypass the security filter chain completely: - - + + @@ -276,9 +276,9 @@ always-use-default-target attribute to "true". This is useful if your application always requires that the user starts at a "home" page, for example: - + - ]]> @@ -315,8 +315,8 @@ - - @@ -341,9 +341,9 @@ - - @@ -380,7 +380,7 @@ requires-channel attribute on <intercept-url>: - + ... ]]> With this configuration in place, if a user attempts to access @@ -388,7 +388,7 @@ HTTPS URL. The available options are "http", "https" or "any". Using the value "any" means that either HTTP or HTTPS can be used. If your application uses non-standard ports for HTTP and/or HTTPS, you can specify a - list of port mappings as follows: ... @@ -404,7 +404,7 @@ Detecting Timeouts You can configure Spring Security to detect the submission of an invalid session ID and redirect the user to an appropriate URL. This is achieved through the - session-management element: session-management element: ... @@ -416,13 +416,13 @@ application, Spring Security supports this out of the box with the following simple additions. First you need to add the following listener to your web.xml file to keep Spring Security updated about session - lifecycle events: org.springframework.security.web.session.HttpSessionEventPublisher -]]> Then add the following lines to your application context: Then add the following lines to your application context: ... @@ -431,7 +431,7 @@ ]]> This will prevent a user from logging in multiple times - a second login will cause the first to be invalidated. Often you would prefer to prevent a - second login, in which case you can use ... @@ -579,8 +579,8 @@ List<OpenIDAttribute> attributes = token.getAttributes();The - - + + ]]> You can also use the after or before attributes if you want your filter to be inserted before or after another filter in the @@ -642,13 +642,13 @@ List<OpenIDAttribute> attributes = token.getAttributes();The AccessDecisionManager for it to make the actual decision: public interface BankService { - + @Secured("IS_AUTHENTICATED_ANONYMOUSLY") public Account readAccount(Long id); - + @Secured("IS_AUTHENTICATED_ANONYMOUSLY") public Account[] findAccounts(); - + @Secured("ROLE_TELLER") public Account post(Account account, double amount); } @@ -661,10 +661,10 @@ List<OpenIDAttribute> attributes = token.getAttributes();The @PreAuthorize("isAnonymous()") public Account readAccount(Long id); - + @PreAuthorize("isAnonymous()") public Account[] findAccounts(); - + @PreAuthorize("hasAuthority('ROLE_TELLER')") public Account post(Account account, double amount); } @@ -675,7 +675,7 @@ List<OpenIDAttribute> attributes = token.getAttributes();The you to apply security to many beans with only a simple declaration. Consider the following example: - ]]> @@ -712,12 +712,12 @@ List<OpenIDAttribute> attributes = token.getAttributes();The global-method-security to the Id of the appropriate AccessDecisionManager bean in the application context: - ... + ... ]]> The syntax for web security is the same, but on the http element: - ... + ... ]]>
@@ -742,7 +742,7 @@ List<OpenIDAttribute> attributes = token.getAttributes();The - ... @@ -750,12 +750,12 @@ List<OpenIDAttribute> attributes = token.getAttributes();The Another common requirement is that another bean in the context may require a reference to the AuthenticationManager. You can easily register an alias for the AuthenticationManager and use this name elsewhere in your - application context. + application context. ... - ... diff --git a/docs/manual/src/docbook/pdf-titlepage.xml b/docs/manual/src/docbook/pdf-titlepage.xml index 13019b85ac..39371f2247 100644 --- a/docs/manual/src/docbook/pdf-titlepage.xml +++ b/docs/manual/src/docbook/pdf-titlepage.xml @@ -40,7 +40,7 @@ - - <subtitle + /> + <subtitle text-align="center" font-size="&hsize4;" space-before="&hsize4space;" font-family="{$title.fontset}" - /> + /> - <corpauthor space-before="0.5em" + <corpauthor space-before="0.5em" font-size="&hsize2;" - /> - - <authorgroup space-before="0.5em" - font-size="&hsize2;" - /> - - <author space-before="0.5em" font-size="&hsize2;"/> - <mediaobject space-before="2em" space-after="2em"/> - <releaseinfo space-before="5em" font-size="&hsize2;"/> + /> - <othercredit space-before="2em" font-weight="normal" font-size="8"/> - <pubdate space-before="0.5em"/> - <revision space-before="0.5em"/> - <revhistory space-before="0.5em"/> - - <abstract space-before="0.5em" + <authorgroup space-before="0.5em" + font-size="&hsize2;" + /> + + <author space-before="0.5em" font-size="&hsize2;"/> + <mediaobject space-before="2em" space-after="2em"/> + <releaseinfo space-before="5em" font-size="&hsize2;"/> + + <othercredit space-before="2em" font-weight="normal" font-size="8"/> + <pubdate space-before="0.5em"/> + <revision space-before="0.5em"/> + <revhistory space-before="0.5em"/> + + <abstract space-before="0.5em" text-align="start" margin-left="0.1in" margin-right="0.1in" font-family="{$body.fontset}" - /> - </t:titlepage-content> + /> + </t:titlepage-content> <t:titlepage-content t:side="verso" text-align="start"> - <copyright space-before="1.5em"/> - <legalnotice space-before="15em"/> - </t:titlepage-content> + <copyright space-before="1.5em"/> + <legalnotice space-before="15em"/> + </t:titlepage-content> <t:titlepage-separator> </t:titlepage-separator> diff --git a/docs/manual/src/docbook/preauth.xml b/docs/manual/src/docbook/preauth.xml index 329f846546..959c778d03 100644 --- a/docs/manual/src/docbook/preauth.xml +++ b/docs/manual/src/docbook/preauth.xml @@ -39,7 +39,7 @@ methods to obtain this information: <programlisting language="java"> protected abstract Object getPreAuthenticatedPrincipal(HttpServletRequest request); - + protected abstract Object getPreAuthenticatedCredentials(HttpServletRequest request); </programlisting> After calling these, the filter will create a @@ -90,7 +90,7 @@ <programlisting language="java"> public interface AuthenticationUserDetailsService { UserDetails loadUserDetails(Authentication token) throws UsernameNotFoundException; - } + } </programlisting> This interface may have also other uses but with pre-authentication it allows access to the authorities which were packaged in the <interfacename>Authentication</interfacename> object, @@ -141,8 +141,8 @@ <!-- Additional http configuration omitted --> <security:custom-filter ref="siteminderFilter" /> </security:http> - - <bean id="siteminderFilter" class= + + <bean id="siteminderFilter" class= "org.springframework.security.web.authentication.preauth.header.RequestHeaderAuthenticationFilter"> <property name="principalRequestHeader" value="SM_USER"/> <property name="authenticationManager" ref="authenticationManager" /> @@ -151,17 +151,17 @@ <bean id="preauthAuthProvider" class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider"> <property name="preAuthenticatedUserDetailsService"> - <bean id="userDetailsServiceWrapper" + <bean id="userDetailsServiceWrapper" class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper"> <property name="userDetailsService" ref="userDetailsService"/> - </bean> + </bean> </property> - </bean> - - <security:authentication-manager alias="authenticationManager"> - <security:authentication-provider ref="preauthAuthProvider" /> - </security-authentication-manager> -]]> + </bean> + + <security:authentication-manager alias="authenticationManager"> + <security:authentication-provider ref="preauthAuthProvider" /> + </security-authentication-manager> +]]> </programlisting> We've assumed here that the security namespace is being used for configuration (hence the user of the <literal>custom-filter</literal>, <literal>authentication-manager</literal> and diff --git a/docs/manual/src/docbook/remember-me-authentication.xml b/docs/manual/src/docbook/remember-me-authentication.xml index 582e064221..65d84cc92a 100644 --- a/docs/manual/src/docbook/remember-me-authentication.xml +++ b/docs/manual/src/docbook/remember-me-authentication.xml @@ -28,12 +28,12 @@ cookie is sent to the browser upon successful interactive authentication, with the cookie being composed as follows: <programlisting> - base64(username + ":" + expirationTime + ":" + + base64(username + ":" + expirationTime + ":" + md5Hex(username + ":" + expirationTime + ":" password + ":" + key)) - + username: As identifiable to the <interfacename>UserDetailsService</interfacename> - password: That matches the one in the retrieved UserDetails - expirationTime: The date and time when the remember-me token expires, + password: That matches the one in the retrieved UserDetails + expirationTime: The date and time when the remember-me token expires, expressed in milliseconds key: A private key to prevent modification of the remember-me token </programlisting></para> @@ -78,7 +78,7 @@ <literal>persistent_logins</literal> table, created using the following SQL (or equivalent): <programlisting> - create table persistent_logins (username varchar(64) not null, series varchar(64) primary key, token varchar(64) not null, last_used timestamp not null) + create table persistent_logins (username varchar(64) not null, series varchar(64) primary key, token varchar(64) not null, last_used timestamp not null) </programlisting></para> <!-- TODO: Add more info on the implementation and behaviour when tokens are stolen etc. Also some info for admins on invalidating tokens using key, or deleting info from db --> </section> @@ -95,7 +95,7 @@ <programlisting language="java"> Authentication autoLogin(HttpServletRequest request, HttpServletResponse response); void loginFail(HttpServletRequest request, HttpServletResponse response); - void loginSuccess(HttpServletRequest request, HttpServletResponse response, + void loginSuccess(HttpServletRequest request, HttpServletResponse response, Authentication successfulAuthentication); </programlisting> Please refer to the JavaDocs for a fuller discussion on what the methods do, although @@ -129,24 +129,24 @@ so can be used with <classname>LogoutFilter</classname> to have the cookie cleared automatically. </para> <para>The beans required in an application context to enable remember-me services are as - follows: <programlisting language="xml"><![CDATA[ + follows: <programlisting language="xml"><![CDATA[ <bean id="rememberMeFilter" class= "org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter"> <property name="rememberMeServices" ref="rememberMeServices"/> - <property name="authenticationManager" ref="theAuthenticationManager" /> + <property name="authenticationManager" ref="theAuthenticationManager" /> </bean> - + <bean id="rememberMeServices" class= "org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices"> <property name="userDetailsService" ref="myUserDetailsService"/> <property name="key" value="springRocks"/> </bean> - + <bean id="rememberMeAuthenticationProvider" class= "org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationProvider"> <property name="key" value="springRocks"/> </bean> -]]> +]]> </programlisting>Don't forget to add your <interfacename>RememberMeServices</interfacename> implementation to your <literal>UsernamePasswordAuthenticationFilter.setRememberMeServices()</literal> diff --git a/docs/manual/src/docbook/runas-auth-provider.xml b/docs/manual/src/docbook/runas-auth-provider.xml index a66414084c..27fde3364d 100644 --- a/docs/manual/src/docbook/runas-auth-provider.xml +++ b/docs/manual/src/docbook/runas-auth-provider.xml @@ -32,7 +32,7 @@ <info><title>Configuration A RunAsManager interface is provided by Spring Security: - Authentication buildRunAs(Authentication authentication, Object object, + Authentication buildRunAs(Authentication authentication, Object object, List<ConfigAttribute> config); boolean supports(ConfigAttribute attribute); boolean supports(Class clazz); @@ -88,7 +88,7 @@ bean context with the same key: diff --git a/docs/manual/src/docbook/samples.xml b/docs/manual/src/docbook/samples.xml index 23f1fd744e..3754e7f0fe 100644 --- a/docs/manual/src/docbook/samples.xml +++ b/docs/manual/src/docbook/samples.xml @@ -47,15 +47,15 @@ Security Debug Information -Authentication object is of type: +Authentication object is of type: org.springframework.security.authentication.UsernamePasswordAuthenticationToken Authentication object as a String: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@1f127853: Principal: org.springframework.security.core.userdetails.User@b07ed00: Username: rod; \ -Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; -credentialsNonExpired: true; AccountNonLocked: true; \ +Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; +credentialsNonExpired: true; AccountNonLocked: true; \ Granted Authorities: ROLE_SUPERVISOR, ROLE_USER; \ Password: [PROTECTED]; Authenticated: true; \ Details: org.springframework.security.web.authentication.WebAuthenticationDetails@0: \ @@ -67,7 +67,7 @@ Authentication object holds the following granted authorities: ROLE_SUPERVISOR (getAuthority(): ROLE_SUPERVISOR) ROLE_USER (getAuthority(): ROLE_USER) -Success! Your web filters appear to be properly configured! +Success! Your web filters appear to be properly configured! Once you successfully receive the above message, return to the sample application's home page and click "Manage". You can then try out the application. Notice that only the diff --git a/docs/manual/src/docbook/security-filter-chain.xml b/docs/manual/src/docbook/security-filter-chain.xml index aa68bf33d5..4fc3c69d28 100644 --- a/docs/manual/src/docbook/security-filter-chain.xml +++ b/docs/manual/src/docbook/security-filter-chain.xml @@ -26,7 +26,7 @@ interfaces. Spring's DelegatingFilterProxy provides the link between web.xml and the application context. When using DelegatingFilterProxy, you will see something like this - in the web.xml file: web.xml file: myFilter org.springframework.web.filter.DelegatingFilterProxy @@ -74,7 +74,7 @@ filterSecurityInterceptor" /> -]]> +]]> The namespace element filter-chain-map is used to set up the security filter chain(s) which are required within the applicationNote that you'll need to include the security namespace in your diff --git a/docs/manual/src/docbook/session-mgmt.xml b/docs/manual/src/docbook/session-mgmt.xml index 1b13f68abf..d73c3453e3 100644 --- a/docs/manual/src/docbook/session-mgmt.xml +++ b/docs/manual/src/docbook/session-mgmt.xml @@ -38,23 +38,23 @@ AbstractAuthenticationProcessingFilter, so if you are using a customized form-login class, for example, you will need to inject it into both of these. In this case, a typical configuration, combining the namespace and custom beans might look like this: - - + + + - - ... - - -]]> +]]>
@@ -87,7 +87,7 @@ org.springframework.security.web.session.HttpSessionEventPublisher - ]]> + ]]> In addition, you will need to add the ConcurrentSessionFilter to your FilterChainProxy. The ConcurrentSessionFilter @@ -97,32 +97,32 @@ to create the FilterChainProxy and other default beans might look like this: - - - - + + + + - - - - - - - + -]]> +]]> Adding the listener to web.xml causes an ApplicationEvent to be published to the Spring diff --git a/docs/manual/src/docbook/springsecurity.xml b/docs/manual/src/docbook/springsecurity.xml index f60be77372..34a05eb143 100644 --- a/docs/manual/src/docbook/springsecurity.xml +++ b/docs/manual/src/docbook/springsecurity.xml @@ -120,7 +120,7 @@ - In this part we cover features which require a knowledge of previous chapters as well diff --git a/docs/manual/src/docbook/taglibs.xml b/docs/manual/src/docbook/taglibs.xml index 5135eba55a..2b9a3953e7 100644 --- a/docs/manual/src/docbook/taglibs.xml +++ b/docs/manual/src/docbook/taglibs.xml @@ -24,7 +24,7 @@ <http> namespace configuration to make sure this service is available). So, for example, you might have<sec:authorize access="hasRole('supervisor')"> - + This content will only be visible to users who have the "supervisor" authority in their list of <tt>GrantedAuthority</tt>s. diff --git a/docs/manual/src/docbook/technical-overview.xml b/docs/manual/src/docbook/technical-overview.xml index 21e813d692..36491dd3ac 100644 --- a/docs/manual/src/docbook/technical-overview.xml +++ b/docs/manual/src/docbook/technical-overview.xml @@ -592,7 +592,7 @@ Successfully authenticated. Security context contains: \ below: diff --git a/docs/manual/src/docbook/web-infrastructure.xml b/docs/manual/src/docbook/web-infrastructure.xml index a49b59115b..daace727e7 100644 --- a/docs/manual/src/docbook/web-infrastructure.xml +++ b/docs/manual/src/docbook/web-infrastructure.xml @@ -29,7 +29,7 @@ interfaces. Spring's DelegatingFilterProxy provides the link between web.xml and the application context. When using DelegatingFilterProxy, you will see something like - this in the web.xml file: web.xml file: myFilter org.springframework.web.filter.DelegatingFilterProxy @@ -77,7 +77,7 @@ filterSecurityInterceptor" /> -]]> +]]> The namespace element filter-chain-map is used to set up the security filter chain(s) which are required within the application Note that you'll need to include the security namespace in your application context @@ -132,7 +132,7 @@
Filter Ordering The order that filters are defined in the chain is very important. Irrespective of which - filters you are actually using, the order should be as follows: + filters you are actually using, the order should be as follows: ChannelProcessingFilter, because it might need to redirect diff --git a/docs/manual/src/docbook/x509-auth-provider.xml b/docs/manual/src/docbook/x509-auth-provider.xml index d0c9171fff..35331ec0eb 100644 --- a/docs/manual/src/docbook/x509-auth-provider.xml +++ b/docs/manual/src/docbook/x509-auth-provider.xml @@ -1,8 +1,8 @@ X.509 Authentication - +
Overview - + The most common use of X.509 certificate authentication is in verifying the identity of a server when using SSL, most commonly when using HTTPS from a browser. The browser will automatically check that the certificate presented by a server has been issued (ie @@ -13,7 +13,7 @@ will authenticate the client by checking that its certificate is signed by an acceptable authority. If a valid certificate has been provided, it can be obtained through the servlet API in an application. Spring Security X.509 module extracts the - certificate using a filter. It maps the certificate to an application user and loads that + certificate using a filter. It maps the certificate to an application user and loads that user's set of granted authorities for use with the standard Spring Security infrastructure. You should be familiar with using certificates and setting up client authentication for your servlet container before attempting to use it with Spring Security. Most of the @@ -22,7 +22,7 @@ you get this working before trying it out with Spring Security
Adding X.509 Authentication to Your Web Application - + Enabling X.509 client authentication is very straightforward. Just add the <x509/> element to your http security namespace configuration. <http> ... @@ -55,31 +55,31 @@
Setting up SSL in Tomcat - - There are some pre-generated certificates in the - samples/certificate directory in the Spring Security project. + + There are some pre-generated certificates in the + samples/certificate directory in the Spring Security project. You can use these to enable SSL for testing if you don't want to generate your own. The file server.jks contains the server certificate, private key and the - issuing certificate authority certificate. There are also some client certificate files - for the users from the sample applications. You can install these in your browser to enable + issuing certificate authority certificate. There are also some client certificate files + for the users from the sample applications. You can install these in your browser to enable SSL client authentication. - To run tomcat with SSL support, drop the server.jks file into the + To run tomcat with SSL support, drop the server.jks file into the tomcat conf directory and add the following connector to the - server.xml file - + server.xml file + <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" scheme="https" secure="true" - clientAuth="true" sslProtocol="TLS" + clientAuth="true" sslProtocol="TLS" keystoreFile="${catalina.home}/conf/server.jks" keystoreType="JKS" keystorePass="password" truststoreFile="${catalina.home}/conf/server.jks" truststoreType="JKS" truststorePass="password" -/> +/> clientAuth can also be set to want if you still want SSL connections to succeed even if the client doesn't provide a certificate. - Clients which don't present a certificate won't be able to access any objects secured by + Clients which don't present a certificate won't be able to access any objects secured by Spring Security unless you use a non-X.509 authentication mechanism, such as form authentication.
diff --git a/itest/context/src/main/java/org/springframework/security/integration/UserRepository.java b/itest/context/src/main/java/org/springframework/security/integration/UserRepository.java index f873447da6..64ab31e912 100755 --- a/itest/context/src/main/java/org/springframework/security/integration/UserRepository.java +++ b/itest/context/src/main/java/org/springframework/security/integration/UserRepository.java @@ -3,5 +3,5 @@ package org.springframework.security.integration; public interface UserRepository { public void doSomething(); - + } diff --git a/itest/context/src/main/java/org/springframework/security/integration/python/PythonInterpreterPrePostInvocationAttributeFactory.java b/itest/context/src/main/java/org/springframework/security/integration/python/PythonInterpreterPrePostInvocationAttributeFactory.java index 70f15f5dc9..a328702ac9 100644 --- a/itest/context/src/main/java/org/springframework/security/integration/python/PythonInterpreterPrePostInvocationAttributeFactory.java +++ b/itest/context/src/main/java/org/springframework/security/integration/python/PythonInterpreterPrePostInvocationAttributeFactory.java @@ -12,10 +12,10 @@ import org.springframework.security.access.prepost.PrePostInvocationAttributeFac public class PythonInterpreterPrePostInvocationAttributeFactory implements PrePostInvocationAttributeFactory{ public PythonInterpreterPrePostInvocationAttributeFactory() { - PythonInterpreter.initialize(System.getProperties(), null, new String[] {}); + PythonInterpreter.initialize(System.getProperties(), null, new String[] {}); } - - + + public PreInvocationAttribute createPreInvocationAttribute(PreFilter preFilter, PreAuthorize preAuthorize) { return new PythonInterpreterPreInvocationAttribute(preAuthorize.value()); } diff --git a/itest/context/src/test/java/org/springframework/security/integration/SEC933ApplicationContextTests.java b/itest/context/src/test/java/org/springframework/security/integration/SEC933ApplicationContextTests.java index 5530ee8937..f7af74e196 100644 --- a/itest/context/src/test/java/org/springframework/security/integration/SEC933ApplicationContextTests.java +++ b/itest/context/src/test/java/org/springframework/security/integration/SEC933ApplicationContextTests.java @@ -15,7 +15,7 @@ public class SEC933ApplicationContextTests { @Autowired private UserDetailsService userDetailsService; - + @Test public void testSimpleApplicationContextBootstrap() throws Exception { assertNotNull(userDetailsService); diff --git a/itest/context/src/test/java/org/springframework/security/integration/SEC936ApplicationContextTests.java b/itest/context/src/test/java/org/springframework/security/integration/SEC936ApplicationContextTests.java index 5aa71b3091..deb89bc0bf 100644 --- a/itest/context/src/test/java/org/springframework/security/integration/SEC936ApplicationContextTests.java +++ b/itest/context/src/test/java/org/springframework/security/integration/SEC936ApplicationContextTests.java @@ -12,7 +12,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Luke Taylor - * @version $Id$ * @since 2.0 */ @ContextConfiguration(locations={"/sec-936-app-context.xml"}) diff --git a/itest/context/src/test/java/org/springframework/security/performance/FilterChainPerformanceTests.java b/itest/context/src/test/java/org/springframework/security/performance/FilterChainPerformanceTests.java index a53b6700be..9a3c32201e 100644 --- a/itest/context/src/test/java/org/springframework/security/performance/FilterChainPerformanceTests.java +++ b/itest/context/src/test/java/org/springframework/security/performance/FilterChainPerformanceTests.java @@ -29,7 +29,6 @@ import org.springframework.util.StopWatch; /** * * @author Luke Taylor - * @version $Id$ * @since 2.0 */ @ContextConfiguration(locations={"/filter-chain-performance-app-context.xml"}) diff --git a/itest/context/src/test/resources/filter-chain-performance-app-context.xml b/itest/context/src/test/resources/filter-chain-performance-app-context.xml index fe882ec464..d162c6d229 100644 --- a/itest/context/src/test/resources/filter-chain-performance-app-context.xml +++ b/itest/context/src/test/resources/filter-chain-performance-app-context.xml @@ -1,105 +1,104 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - - + + + + + + + diff --git a/itest/context/src/test/resources/log4j.properties b/itest/context/src/test/resources/log4j.properties index 6f17212f16..8dee55e627 100644 --- a/itest/context/src/test/resources/log4j.properties +++ b/itest/context/src/test/resources/log4j.properties @@ -1,6 +1,5 @@ # Logging # -# $Id$ log4j.rootLogger=WARN, stdout diff --git a/itest/misc/pom.xml b/itest/misc/pom.xml index 6ea6c9f8a6..fbda2da788 100644 --- a/itest/misc/pom.xml +++ b/itest/misc/pom.xml @@ -18,7 +18,7 @@ ${spring.version} test - org.apache.maven.plugins @@ -547,7 +547,7 @@ org.springframework spring-tx - + org.springframework spring-beans @@ -567,7 +567,7 @@ org.aspectj aspectjweaver 1.6.5 - + cglib cglib-nodep @@ -579,7 +579,7 @@ net.sf.ehcache ehcache 1.6.2 - true + true commons-collections @@ -631,7 +631,7 @@ UTF-8 - UTF-8 + UTF-8 3.0.0.RELEASE 1.1.2 6.1.22 diff --git a/readme.txt b/readme.txt index 562a5884e9..eb79d9f553 100644 --- a/readme.txt +++ b/readme.txt @@ -70,4 +70,3 @@ Links to the forums, and other useful resources are available from the web site. -$Id$ diff --git a/samples/aspectj/src/main/java/sample/aspectj/SecuredService.java b/samples/aspectj/src/main/java/sample/aspectj/SecuredService.java index fee03b106b..b6e9e7f075 100644 --- a/samples/aspectj/src/main/java/sample/aspectj/SecuredService.java +++ b/samples/aspectj/src/main/java/sample/aspectj/SecuredService.java @@ -7,7 +7,6 @@ import org.springframework.security.access.annotation.Secured; * * @author Mike Wiesner * @since 3.0 - * @version $Id$ */ @Secured("ROLE_USER") public class SecuredService { diff --git a/samples/aspectj/src/main/java/sample/aspectj/Service.java b/samples/aspectj/src/main/java/sample/aspectj/Service.java index 6a65009f62..8e450a6045 100644 --- a/samples/aspectj/src/main/java/sample/aspectj/Service.java +++ b/samples/aspectj/src/main/java/sample/aspectj/Service.java @@ -7,7 +7,6 @@ import org.springframework.security.access.annotation.Secured; * * @author Mike Wiesner * @since 1.0 - * @version $Id$ */ public class Service { diff --git a/samples/cas/client/src/main/java/Dummy.java b/samples/cas/client/src/main/java/Dummy.java index e8f5b26783..efdf8171a2 100644 --- a/samples/cas/client/src/main/java/Dummy.java +++ b/samples/cas/client/src/main/java/Dummy.java @@ -1,7 +1,6 @@ /** * * @author Luke Taylor - * @version $Id$ */ public class Dummy { } diff --git a/samples/cas/client/src/main/webapp/WEB-INF/classes/log4j.properties b/samples/cas/client/src/main/webapp/WEB-INF/classes/log4j.properties index a8f1ba9ce8..25c0b7ce8d 100644 --- a/samples/cas/client/src/main/webapp/WEB-INF/classes/log4j.properties +++ b/samples/cas/client/src/main/webapp/WEB-INF/classes/log4j.properties @@ -1,19 +1,19 @@ -# Global logging configuration -log4j.rootLogger=INFO, stdout, fileout - -log4j.logger.org.springframework.security=DEBUG - -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.conversionPattern=[%p,%c{1},%t] %m%n - -# Rolling log file output... -log4j.appender.fileout=org.apache.log4j.RollingFileAppender -log4j.appender.fileout.File=spring-security-cas-client.log -log4j.appender.fileout.MaxFileSize=1024KB -log4j.appender.fileout.MaxBackupIndex=1 -log4j.appender.fileout.layout=org.apache.log4j.PatternLayout -log4j.appender.fileout.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1},%t:%L - %m%n - - +# Global logging configuration +log4j.rootLogger=INFO, stdout, fileout + +log4j.logger.org.springframework.security=DEBUG + +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.conversionPattern=[%p,%c{1},%t] %m%n + +# Rolling log file output... +log4j.appender.fileout=org.apache.log4j.RollingFileAppender +log4j.appender.fileout.File=spring-security-cas-client.log +log4j.appender.fileout.MaxFileSize=1024KB +log4j.appender.fileout.MaxBackupIndex=1 +log4j.appender.fileout.layout=org.apache.log4j.PatternLayout +log4j.appender.fileout.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1},%t:%L - %m%n + + diff --git a/samples/cas/client/src/main/webapp/WEB-INF/web.xml b/samples/cas/client/src/main/webapp/WEB-INF/web.xml index 06f7840c2c..460607cd4d 100644 --- a/samples/cas/client/src/main/webapp/WEB-INF/web.xml +++ b/samples/cas/client/src/main/webapp/WEB-INF/web.xml @@ -1,72 +1,71 @@ - - - - - - Spring Security CAS Demo Application - - - - contextConfigLocation - - /WEB-INF/applicationContext-security.xml - - - - - log4jConfigLocation - /WEB-INF/classes/log4j.properties - - - - webAppRootKey - cas.root - - - - CAS Single Sign Out Filter - org.jasig.cas.client.session.SingleSignOutFilter - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - - CAS Single Sign Out Filter - /* - - - - springSecurityFilterChain - /* - - - - - org.jasig.cas.client.session.SingleSignOutHttpSessionListener - - - - org.springframework.web.context.ContextLoaderListener - - - - org.springframework.web.util.Log4jConfigListener - - - + + + + + + Spring Security CAS Demo Application + + + + contextConfigLocation + + /WEB-INF/applicationContext-security.xml + + + + + log4jConfigLocation + /WEB-INF/classes/log4j.properties + + + + webAppRootKey + cas.root + + + + CAS Single Sign Out Filter + org.jasig.cas.client.session.SingleSignOutFilter + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + + CAS Single Sign Out Filter + /* + + + + springSecurityFilterChain + /* + + + + + org.jasig.cas.client.session.SingleSignOutHttpSessionListener + + + + org.springframework.web.context.ContextLoaderListener + + + + org.springframework.web.util.Log4jConfigListener + + + diff --git a/samples/cas/client/src/main/webapp/index.jsp b/samples/cas/client/src/main/webapp/index.jsp index 9f056599b6..c815d484a3 100644 --- a/samples/cas/client/src/main/webapp/index.jsp +++ b/samples/cas/client/src/main/webapp/index.jsp @@ -1,11 +1,11 @@ - - -

Home Page

-

Anyone can view this page.

- -

Your principal object is....: <%= request.getUserPrincipal() %>

- -

Secure page

-

Extremely secure page

- + + +

Home Page

+

Anyone can view this page.

+ +

Your principal object is....: <%= request.getUserPrincipal() %>

+ +

Secure page

+

Extremely secure page

+ \ No newline at end of file diff --git a/samples/cas/client/src/main/webapp/secure/extreme/index.jsp b/samples/cas/client/src/main/webapp/secure/extreme/index.jsp index f7df8f9a80..c5ff40bfef 100644 --- a/samples/cas/client/src/main/webapp/secure/extreme/index.jsp +++ b/samples/cas/client/src/main/webapp/secure/extreme/index.jsp @@ -1,9 +1,9 @@ - - -

VERY Secure Page

-This is a protected page. You can only see me if you are a supervisor. - -

Home -

Logout - + + +

VERY Secure Page

+This is a protected page. You can only see me if you are a supervisor. + +

Home +

Logout + \ No newline at end of file diff --git a/samples/cas/client/src/main/webapp/secure/index.jsp b/samples/cas/client/src/main/webapp/secure/index.jsp index 0c960942a7..97d9b216d4 100644 --- a/samples/cas/client/src/main/webapp/secure/index.jsp +++ b/samples/cas/client/src/main/webapp/secure/index.jsp @@ -1,15 +1,15 @@ - - -

Secure Page

-This is a protected page. You can get to me if you've been remembered, -or if you've authenticated this session.

- -<%if (request.isUserInRole("ROLE_SUPERVISOR")) { %> - You are a supervisor! You can therefore see the extremely secure page.

-<% } %> - - -

Home -

Logout - + + +

Secure Page

+This is a protected page. You can get to me if you've been remembered, +or if you've authenticated this session.

+ +<%if (request.isUserInRole("ROLE_SUPERVISOR")) { %> + You are a supervisor! You can therefore see the extremely secure page.

+<% } %> + + +

Home +

Logout + \ No newline at end of file diff --git a/samples/contacts/client/client.properties b/samples/contacts/client/client.properties index 00e0fadf67..9f3feee9ea 100644 --- a/samples/contacts/client/client.properties +++ b/samples/contacts/client/client.properties @@ -1,7 +1,6 @@ # Properties file with server URL settings for remote access. # Applied by PropertyPlaceholderConfigurer from "clientContext.xml". # -# $Id$ serverName=localhost httpPort=8080 diff --git a/samples/contacts/pom.xml b/samples/contacts/pom.xml index 751f5fa812..5e3a945055 100644 --- a/samples/contacts/pom.xml +++ b/samples/contacts/pom.xml @@ -34,7 +34,7 @@ org.springframework spring-webmvc compile - + org.springframework spring-jdbc diff --git a/samples/contacts/src/main/java/sample/contact/AddDeleteContactController.java b/samples/contacts/src/main/java/sample/contact/AddDeleteContactController.java index bf634b9e62..35e88e07b3 100644 --- a/samples/contacts/src/main/java/sample/contact/AddDeleteContactController.java +++ b/samples/contacts/src/main/java/sample/contact/AddDeleteContactController.java @@ -14,7 +14,6 @@ import org.springframework.web.servlet.ModelAndView; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ @Controller diff --git a/samples/contacts/src/main/java/sample/contact/AddPermission.java b/samples/contacts/src/main/java/sample/contact/AddPermission.java index ba4a2e60d2..6c260fde1e 100644 --- a/samples/contacts/src/main/java/sample/contact/AddPermission.java +++ b/samples/contacts/src/main/java/sample/contact/AddPermission.java @@ -21,7 +21,6 @@ import org.springframework.security.acls.domain.BasePermission; * Model object for add permission use case. * * @author Ben Alex - * @version $Id$ */ public class AddPermission { //~ Instance fields ================================================================================================ diff --git a/samples/contacts/src/main/java/sample/contact/AddPermissionValidator.java b/samples/contacts/src/main/java/sample/contact/AddPermissionValidator.java index 06ac40fc2a..cdea87f9ae 100644 --- a/samples/contacts/src/main/java/sample/contact/AddPermissionValidator.java +++ b/samples/contacts/src/main/java/sample/contact/AddPermissionValidator.java @@ -25,7 +25,6 @@ import org.springframework.validation.Validator; * Validates {@link AddPermission}. * * @author Ben Alex - * @version $Id$ */ public class AddPermissionValidator implements Validator { //~ Methods ======================================================================================================== diff --git a/samples/contacts/src/main/java/sample/contact/AdminPermissionController.java b/samples/contacts/src/main/java/sample/contact/AdminPermissionController.java index 928b4b29f5..812a41c967 100644 --- a/samples/contacts/src/main/java/sample/contact/AdminPermissionController.java +++ b/samples/contacts/src/main/java/sample/contact/AdminPermissionController.java @@ -35,7 +35,6 @@ import org.springframework.web.servlet.ModelAndView; * permissions for contacts. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ @Controller diff --git a/samples/contacts/src/main/java/sample/contact/Contact.java b/samples/contacts/src/main/java/sample/contact/Contact.java index d96fb36057..fc1d034a57 100644 --- a/samples/contacts/src/main/java/sample/contact/Contact.java +++ b/samples/contacts/src/main/java/sample/contact/Contact.java @@ -22,7 +22,6 @@ import java.io.Serializable; * Represents a contact. * * @author Ben Alex - * @version $Id$ */ public class Contact implements Serializable { //~ Instance fields ================================================================================================ diff --git a/samples/contacts/src/main/java/sample/contact/ContactDao.java b/samples/contacts/src/main/java/sample/contact/ContactDao.java index 7ffbea38d0..a2d48ca75d 100644 --- a/samples/contacts/src/main/java/sample/contact/ContactDao.java +++ b/samples/contacts/src/main/java/sample/contact/ContactDao.java @@ -22,7 +22,6 @@ import java.util.List; * Provides access to the application's persistence layer. * * @author Ben Alex - * @version $Id$ */ public interface ContactDao { //~ Methods ======================================================================================================== diff --git a/samples/contacts/src/main/java/sample/contact/ContactDaoSpring.java b/samples/contacts/src/main/java/sample/contact/ContactDaoSpring.java index 0122f3323b..fb341215cd 100644 --- a/samples/contacts/src/main/java/sample/contact/ContactDaoSpring.java +++ b/samples/contacts/src/main/java/sample/contact/ContactDaoSpring.java @@ -33,7 +33,6 @@ import javax.sql.DataSource; * Base implementation of {@link ContactDao} that uses Spring JDBC services. * * @author Ben Alex - * @version $Id$ */ public class ContactDaoSpring extends JdbcDaoSupport implements ContactDao { //~ Instance fields ================================================================================================ diff --git a/samples/contacts/src/main/java/sample/contact/ContactManager.java b/samples/contacts/src/main/java/sample/contact/ContactManager.java index ea9a4c3039..15ac69f6b6 100644 --- a/samples/contacts/src/main/java/sample/contact/ContactManager.java +++ b/samples/contacts/src/main/java/sample/contact/ContactManager.java @@ -26,7 +26,6 @@ import java.util.List; * Interface for the application's services layer. * * @author Ben Alex - * @version $Id$ */ public interface ContactManager { //~ Methods ======================================================================================================== diff --git a/samples/contacts/src/main/java/sample/contact/ContactManagerBackend.java b/samples/contacts/src/main/java/sample/contact/ContactManagerBackend.java index 62a7168edf..051ba22fa8 100644 --- a/samples/contacts/src/main/java/sample/contact/ContactManagerBackend.java +++ b/samples/contacts/src/main/java/sample/contact/ContactManagerBackend.java @@ -46,7 +46,6 @@ import java.util.Random; * Concrete implementation of {@link ContactManager}. * * @author Ben Alex - * @version $Id$ */ @Transactional public class ContactManagerBackend extends ApplicationObjectSupport implements ContactManager, InitializingBean { diff --git a/samples/contacts/src/main/java/sample/contact/DataSourcePopulator.java b/samples/contacts/src/main/java/sample/contact/DataSourcePopulator.java index 8028c82743..1edeb4fc5b 100644 --- a/samples/contacts/src/main/java/sample/contact/DataSourcePopulator.java +++ b/samples/contacts/src/main/java/sample/contact/DataSourcePopulator.java @@ -43,7 +43,6 @@ import org.springframework.util.Assert; * Populates the Contacts in-memory database with contact and ACL information. * * @author Ben Alex - * @version $Id$ */ public class DataSourcePopulator implements InitializingBean { //~ Instance fields ================================================================================================ diff --git a/samples/contacts/src/main/java/sample/contact/IndexController.java b/samples/contacts/src/main/java/sample/contact/IndexController.java index 5c1fec5347..72cf8bb3d7 100644 --- a/samples/contacts/src/main/java/sample/contact/IndexController.java +++ b/samples/contacts/src/main/java/sample/contact/IndexController.java @@ -20,7 +20,6 @@ import org.springframework.web.servlet.ModelAndView; * Controller which handles simple, single request use cases such as index pages and contact deletion. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ @Controller diff --git a/samples/contacts/src/main/java/sample/contact/WebContact.java b/samples/contacts/src/main/java/sample/contact/WebContact.java index 90594bd8f2..ad3dd32f0e 100644 --- a/samples/contacts/src/main/java/sample/contact/WebContact.java +++ b/samples/contacts/src/main/java/sample/contact/WebContact.java @@ -19,7 +19,6 @@ package sample.contact; * An object that represents user-editable sections of a {@link Contact}. * * @author Ben Alex - * @version $Id$ */ public class WebContact { //~ Instance fields ================================================================================================ diff --git a/samples/contacts/src/main/java/sample/contact/WebContactValidator.java b/samples/contacts/src/main/java/sample/contact/WebContactValidator.java index bc5b824b75..c161a981d0 100644 --- a/samples/contacts/src/main/java/sample/contact/WebContactValidator.java +++ b/samples/contacts/src/main/java/sample/contact/WebContactValidator.java @@ -23,7 +23,6 @@ import org.springframework.validation.Validator; * Validates {@link WebContact}. * * @author Ben Alex - * @version $Id$ */ public class WebContactValidator implements Validator { //~ Methods ======================================================================================================== diff --git a/samples/contacts/src/main/resources/applicationContext-common-authorization.xml b/samples/contacts/src/main/resources/applicationContext-common-authorization.xml index 0258ee7f1d..820a8c32b7 100644 --- a/samples/contacts/src/main/resources/applicationContext-common-authorization.xml +++ b/samples/contacts/src/main/resources/applicationContext-common-authorization.xml @@ -9,7 +9,6 @@ diff --git a/samples/contacts/src/main/resources/applicationContext-common-business.xml b/samples/contacts/src/main/resources/applicationContext-common-business.xml index 71c59c26a9..6cbfb9a375 100644 --- a/samples/contacts/src/main/resources/applicationContext-common-business.xml +++ b/samples/contacts/src/main/resources/applicationContext-common-business.xml @@ -5,7 +5,6 @@ - - Used by all artifacts. - - - $Id$ --> diff --git a/samples/contacts/src/main/webapp/WEB-INF/web.xml b/samples/contacts/src/main/webapp/WEB-INF/web.xml index 736affbafd..f1783027fa 100644 --- a/samples/contacts/src/main/webapp/WEB-INF/web.xml +++ b/samples/contacts/src/main/webapp/WEB-INF/web.xml @@ -3,7 +3,6 @@ diff --git a/samples/dms/src/main/resources/applicationContext-dms-secure.xml b/samples/dms/src/main/resources/applicationContext-dms-secure.xml index 4d008a5049..33252041fa 100755 --- a/samples/dms/src/main/resources/applicationContext-dms-secure.xml +++ b/samples/dms/src/main/resources/applicationContext-dms-secure.xml @@ -3,7 +3,6 @@ diff --git a/samples/dms/src/test/java/DmsIntegrationTests.java b/samples/dms/src/test/java/DmsIntegrationTests.java index ead85272fc..5dc90ac67b 100755 --- a/samples/dms/src/test/java/DmsIntegrationTests.java +++ b/samples/dms/src/test/java/DmsIntegrationTests.java @@ -17,7 +17,6 @@ import sample.dms.DocumentDao; * Basic integration test for DMS sample. * * @author Ben Alex - * @version $Id$ * */ @ContextConfiguration(locations={"classpath:applicationContext-dms-shared.xml", "classpath:applicationContext-dms-insecure.xml"}) diff --git a/samples/dms/src/test/java/SecureDmsIntegrationTests.java b/samples/dms/src/test/java/SecureDmsIntegrationTests.java index f562ecdfc5..833665b59c 100755 --- a/samples/dms/src/test/java/SecureDmsIntegrationTests.java +++ b/samples/dms/src/test/java/SecureDmsIntegrationTests.java @@ -9,7 +9,6 @@ import org.springframework.test.context.ContextConfiguration; * Basic integration test for DMS sample when security has been added. * * @author Ben Alex - * @version $Id$ * */ @ContextConfiguration(locations={"classpath:applicationContext-dms-shared.xml", "classpath:applicationContext-dms-secure.xml"}) diff --git a/samples/ldap/src/main/webapp/WEB-INF/classes/log4j.properties b/samples/ldap/src/main/webapp/WEB-INF/classes/log4j.properties index 21fb694421..a09253a621 100644 --- a/samples/ldap/src/main/webapp/WEB-INF/classes/log4j.properties +++ b/samples/ldap/src/main/webapp/WEB-INF/classes/log4j.properties @@ -1,18 +1,18 @@ -# Global logging configuration -log4j.rootLogger=INFO, stdout, fileout - -log4j.logger.org.springframework.security=DEBUG - -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.conversionPattern=[%p,%c{1},%t] %m%n - -# Rolling log file output... -log4j.appender.fileout=org.apache.log4j.FileAppender -log4j.appender.fileout.File=spring-security-ldap.log -log4j.appender.fileout.Append=false -log4j.appender.fileout.layout=org.apache.log4j.PatternLayout -log4j.appender.fileout.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1},%t:%L - %m%n - - +# Global logging configuration +log4j.rootLogger=INFO, stdout, fileout + +log4j.logger.org.springframework.security=DEBUG + +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.conversionPattern=[%p,%c{1},%t] %m%n + +# Rolling log file output... +log4j.appender.fileout=org.apache.log4j.FileAppender +log4j.appender.fileout.File=spring-security-ldap.log +log4j.appender.fileout.Append=false +log4j.appender.fileout.layout=org.apache.log4j.PatternLayout +log4j.appender.fileout.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1},%t:%L - %m%n + + diff --git a/samples/ldap/src/main/webapp/WEB-INF/web.xml b/samples/ldap/src/main/webapp/WEB-INF/web.xml index d49a01823a..9304dc9792 100644 --- a/samples/ldap/src/main/webapp/WEB-INF/web.xml +++ b/samples/ldap/src/main/webapp/WEB-INF/web.xml @@ -1,49 +1,48 @@ - - - - - - Spring Security LDAP Demo Application - - - - contextConfigLocation - - /WEB-INF/applicationContext-security.xml - - - - - webAppRootKey - ldap.root - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - - springSecurityFilterChain - /* - - - - - org.springframework.web.context.ContextLoaderListener - - - + + + + + + Spring Security LDAP Demo Application + + + + contextConfigLocation + + /WEB-INF/applicationContext-security.xml + + + + + webAppRootKey + ldap.root + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + + springSecurityFilterChain + /* + + + + + org.springframework.web.context.ContextLoaderListener + + + diff --git a/samples/ldap/src/main/webapp/index.jsp b/samples/ldap/src/main/webapp/index.jsp index 9f056599b6..c815d484a3 100644 --- a/samples/ldap/src/main/webapp/index.jsp +++ b/samples/ldap/src/main/webapp/index.jsp @@ -1,11 +1,11 @@ - - -

Home Page

-

Anyone can view this page.

- -

Your principal object is....: <%= request.getUserPrincipal() %>

- -

Secure page

-

Extremely secure page

- + + +

Home Page

+

Anyone can view this page.

+ +

Your principal object is....: <%= request.getUserPrincipal() %>

+ +

Secure page

+

Extremely secure page

+ \ No newline at end of file diff --git a/samples/ldap/src/main/webapp/secure/extreme/index.jsp b/samples/ldap/src/main/webapp/secure/extreme/index.jsp index 5cc73bb8b6..2804561673 100644 --- a/samples/ldap/src/main/webapp/secure/extreme/index.jsp +++ b/samples/ldap/src/main/webapp/secure/extreme/index.jsp @@ -1,10 +1,10 @@ - - - -

VERY Secure Page

-This is a protected page. You can only see me if you are a supervisor. - -

Home -

Logout - + + + +

VERY Secure Page

+This is a protected page. You can only see me if you are a supervisor. + +

Home +

Logout + \ No newline at end of file diff --git a/samples/ldap/src/main/webapp/secure/index.jsp b/samples/ldap/src/main/webapp/secure/index.jsp index b774c40ed8..97d9b216d4 100644 --- a/samples/ldap/src/main/webapp/secure/index.jsp +++ b/samples/ldap/src/main/webapp/secure/index.jsp @@ -1,15 +1,15 @@ - - -

Secure Page

-This is a protected page. You can get to me if you've been remembered, -or if you've authenticated this session.

+ + +

Secure Page

+This is a protected page. You can get to me if you've been remembered, +or if you've authenticated this session.

<%if (request.isUserInRole("ROLE_SUPERVISOR")) { %> You are a supervisor! You can therefore see the extremely secure page.

<% } %> - -

Home -

Logout - + +

Home +

Logout + \ No newline at end of file diff --git a/samples/openid/src/main/java/zzz/Dummy.java b/samples/openid/src/main/java/zzz/Dummy.java index 2e17f69cd6..ca5d30edb5 100644 --- a/samples/openid/src/main/java/zzz/Dummy.java +++ b/samples/openid/src/main/java/zzz/Dummy.java @@ -1,7 +1,6 @@ package zzz; /** * @author Luke Taylor - * @version $Id$ */ public class Dummy { } diff --git a/samples/openid/src/main/webapp/WEB-INF/applicationContext-security.xml b/samples/openid/src/main/webapp/WEB-INF/applicationContext-security.xml index e7007eda76..4adbf90c69 100644 --- a/samples/openid/src/main/webapp/WEB-INF/applicationContext-security.xml +++ b/samples/openid/src/main/webapp/WEB-INF/applicationContext-security.xml @@ -1,36 +1,35 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/openid/src/main/webapp/WEB-INF/classes/log4j.properties b/samples/openid/src/main/webapp/WEB-INF/classes/log4j.properties index ddd6feb06c..fb9a11852c 100644 --- a/samples/openid/src/main/webapp/WEB-INF/classes/log4j.properties +++ b/samples/openid/src/main/webapp/WEB-INF/classes/log4j.properties @@ -1,12 +1,12 @@ -# Global logging configuration -log4j.rootLogger=INFO, stdout - -log4j.logger.org.springframework.security=DEBUG - -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.conversionPattern=[%p,%c{1}] %m%n - - - +# Global logging configuration +log4j.rootLogger=INFO, stdout + +log4j.logger.org.springframework.security=DEBUG + +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.conversionPattern=[%p,%c{1}] %m%n + + + diff --git a/samples/openid/src/main/webapp/WEB-INF/web.xml b/samples/openid/src/main/webapp/WEB-INF/web.xml index ae15d0b118..600ab6d539 100644 --- a/samples/openid/src/main/webapp/WEB-INF/web.xml +++ b/samples/openid/src/main/webapp/WEB-INF/web.xml @@ -1,58 +1,57 @@ - - - - - - Spring Security OpenID Demo Application - - - - contextConfigLocation - - /WEB-INF/applicationContext-security.xml - - - - - log4jConfigLocation - /WEB-INF/classes/log4j.properties - - - - webAppRootKey - openid.root - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - - springSecurityFilterChain - /* - - - - - org.springframework.web.context.ContextLoaderListener - - - - org.springframework.web.util.Log4jConfigListener - - - + + + + + + Spring Security OpenID Demo Application + + + + contextConfigLocation + + /WEB-INF/applicationContext-security.xml + + + + + log4jConfigLocation + /WEB-INF/classes/log4j.properties + + + + webAppRootKey + openid.root + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + + springSecurityFilterChain + /* + + + + + org.springframework.web.context.ContextLoaderListener + + + + org.springframework.web.util.Log4jConfigListener + + + diff --git a/samples/openid/src/main/webapp/index.jsp b/samples/openid/src/main/webapp/index.jsp index 9f056599b6..c815d484a3 100644 --- a/samples/openid/src/main/webapp/index.jsp +++ b/samples/openid/src/main/webapp/index.jsp @@ -1,11 +1,11 @@ - - -

Home Page

-

Anyone can view this page.

- -

Your principal object is....: <%= request.getUserPrincipal() %>

- -

Secure page

-

Extremely secure page

- + + +

Home Page

+

Anyone can view this page.

+ +

Your principal object is....: <%= request.getUserPrincipal() %>

+ +

Secure page

+

Extremely secure page

+ \ No newline at end of file diff --git a/samples/openid/src/main/webapp/secure/extreme/index.jsp b/samples/openid/src/main/webapp/secure/extreme/index.jsp index f7df8f9a80..c5ff40bfef 100644 --- a/samples/openid/src/main/webapp/secure/extreme/index.jsp +++ b/samples/openid/src/main/webapp/secure/extreme/index.jsp @@ -1,9 +1,9 @@ - - -

VERY Secure Page

-This is a protected page. You can only see me if you are a supervisor. - -

Home -

Logout - + + +

VERY Secure Page

+This is a protected page. You can only see me if you are a supervisor. + +

Home +

Logout + \ No newline at end of file diff --git a/samples/openid/src/main/webapp/secure/index.jsp b/samples/openid/src/main/webapp/secure/index.jsp index b774c40ed8..97d9b216d4 100644 --- a/samples/openid/src/main/webapp/secure/index.jsp +++ b/samples/openid/src/main/webapp/secure/index.jsp @@ -1,15 +1,15 @@ - - -

Secure Page

-This is a protected page. You can get to me if you've been remembered, -or if you've authenticated this session.

+ + +

Secure Page

+This is a protected page. You can get to me if you've been remembered, +or if you've authenticated this session.

<%if (request.isUserInRole("ROLE_SUPERVISOR")) { %> You are a supervisor! You can therefore see the extremely secure page.

<% } %> - -

Home -

Logout - + +

Home +

Logout + \ No newline at end of file diff --git a/samples/pom.xml b/samples/pom.xml index 305c24fc88..354581c7bd 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -16,14 +16,14 @@ preauth openid ldap - cas - + cas + javax.servlet servlet-api - + javax.servlet jstl diff --git a/samples/preauth/src/main/webapp/WEB-INF/applicationContext-security.xml b/samples/preauth/src/main/webapp/WEB-INF/applicationContext-security.xml index 2ff514d2c6..8886144ce6 100644 --- a/samples/preauth/src/main/webapp/WEB-INF/applicationContext-security.xml +++ b/samples/preauth/src/main/webapp/WEB-INF/applicationContext-security.xml @@ -1,93 +1,92 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + diff --git a/samples/preauth/src/main/webapp/WEB-INF/classes/log4j.properties b/samples/preauth/src/main/webapp/WEB-INF/classes/log4j.properties index 5a78fdb39c..f491147825 100644 --- a/samples/preauth/src/main/webapp/WEB-INF/classes/log4j.properties +++ b/samples/preauth/src/main/webapp/WEB-INF/classes/log4j.properties @@ -1,20 +1,20 @@ -# Global logging configuration -log4j.rootLogger=INFO, stdout, fileout - -log4j.logger.org.springframework.security=DEBUG, stdout, fileout - -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.conversionPattern=[%p,%c{1},%t] %m%n - -# Rolling log file output... -log4j.appender.fileout=org.apache.log4j.RollingFileAppender -log4j.appender.fileout.File=spring-security-preauth.log -#log4j.appender.fileout.File=${webapp.root}/WEB-INF/log4j.log -log4j.appender.fileout.MaxFileSize=1024KB -log4j.appender.fileout.MaxBackupIndex=1 -log4j.appender.fileout.layout=org.apache.log4j.PatternLayout -log4j.appender.fileout.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1},%t:%L - %m%n - - +# Global logging configuration +log4j.rootLogger=INFO, stdout, fileout + +log4j.logger.org.springframework.security=DEBUG, stdout, fileout + +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.conversionPattern=[%p,%c{1},%t] %m%n + +# Rolling log file output... +log4j.appender.fileout=org.apache.log4j.RollingFileAppender +log4j.appender.fileout.File=spring-security-preauth.log +#log4j.appender.fileout.File=${webapp.root}/WEB-INF/log4j.log +log4j.appender.fileout.MaxFileSize=1024KB +log4j.appender.fileout.MaxBackupIndex=1 +log4j.appender.fileout.layout=org.apache.log4j.PatternLayout +log4j.appender.fileout.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1},%t:%L - %m%n + + diff --git a/samples/preauth/src/main/webapp/WEB-INF/web.xml b/samples/preauth/src/main/webapp/WEB-INF/web.xml index acbfc088af..d4f3a38ada 100644 --- a/samples/preauth/src/main/webapp/WEB-INF/web.xml +++ b/samples/preauth/src/main/webapp/WEB-INF/web.xml @@ -1,65 +1,64 @@ - - - - - - Spring Security Preauthentication Demo Application - - - - contextConfigLocation - - /WEB-INF/applicationContext-security.xml - - - - - filterChainProxy - org.springframework.web.filter.DelegatingFilterProxy - - - - filterChainProxy - /* - - - - - org.springframework.web.context.ContextLoaderListener - - - - BASIC - Preauth Realm - - - - ROLE_USER - - - ROLE_SUPERVISOR - - - - All areas - /* - - - ROLE_USER - - - - + + + + + + Spring Security Preauthentication Demo Application + + + + contextConfigLocation + + /WEB-INF/applicationContext-security.xml + + + + + filterChainProxy + org.springframework.web.filter.DelegatingFilterProxy + + + + filterChainProxy + /* + + + + + org.springframework.web.context.ContextLoaderListener + + + + BASIC + Preauth Realm + + + + ROLE_USER + + + ROLE_SUPERVISOR + + + + All areas + /* + + + ROLE_USER + + + + diff --git a/samples/preauth/src/main/webapp/index.jsp b/samples/preauth/src/main/webapp/index.jsp index 9f056599b6..c815d484a3 100644 --- a/samples/preauth/src/main/webapp/index.jsp +++ b/samples/preauth/src/main/webapp/index.jsp @@ -1,11 +1,11 @@ - - -

Home Page

-

Anyone can view this page.

- -

Your principal object is....: <%= request.getUserPrincipal() %>

- -

Secure page

-

Extremely secure page

- + + +

Home Page

+

Anyone can view this page.

+ +

Your principal object is....: <%= request.getUserPrincipal() %>

+ +

Secure page

+

Extremely secure page

+ \ No newline at end of file diff --git a/samples/preauth/src/main/webapp/secure/extreme/index.jsp b/samples/preauth/src/main/webapp/secure/extreme/index.jsp index 5cc73bb8b6..2804561673 100644 --- a/samples/preauth/src/main/webapp/secure/extreme/index.jsp +++ b/samples/preauth/src/main/webapp/secure/extreme/index.jsp @@ -1,10 +1,10 @@ - - - -

VERY Secure Page

-This is a protected page. You can only see me if you are a supervisor. - -

Home -

Logout - + + + +

VERY Secure Page

+This is a protected page. You can only see me if you are a supervisor. + +

Home +

Logout + \ No newline at end of file diff --git a/samples/preauth/src/main/webapp/secure/index.jsp b/samples/preauth/src/main/webapp/secure/index.jsp index b774c40ed8..97d9b216d4 100644 --- a/samples/preauth/src/main/webapp/secure/index.jsp +++ b/samples/preauth/src/main/webapp/secure/index.jsp @@ -1,15 +1,15 @@ - - -

Secure Page

-This is a protected page. You can get to me if you've been remembered, -or if you've authenticated this session.

+ + +

Secure Page

+This is a protected page. You can get to me if you've been remembered, +or if you've authenticated this session.

<%if (request.isUserInRole("ROLE_SUPERVISOR")) { %> You are a supervisor! You can therefore see the extremely secure page.

<% } %> - -

Home -

Logout - + +

Home +

Logout + \ No newline at end of file diff --git a/samples/tutorial/src/main/java/bigbank/Account.java b/samples/tutorial/src/main/java/bigbank/Account.java index df031b5af9..5d3fbee0d5 100644 --- a/samples/tutorial/src/main/java/bigbank/Account.java +++ b/samples/tutorial/src/main/java/bigbank/Account.java @@ -7,7 +7,6 @@ package bigbank; * as opposed to what they ideally would be doing. * * @author Ben Alex - * @version $Id$ */ public class Account { private long id = -1; diff --git a/samples/tutorial/src/main/java/bigbank/SeedData.java b/samples/tutorial/src/main/java/bigbank/SeedData.java index 182ac392b4..6eaf6ec16c 100644 --- a/samples/tutorial/src/main/java/bigbank/SeedData.java +++ b/samples/tutorial/src/main/java/bigbank/SeedData.java @@ -13,9 +13,9 @@ public class SeedData implements InitializingBean{ bankDao.createOrUpdateAccount(new Account("scott")); bankDao.createOrUpdateAccount(new Account("peter")); } - + public void setBankDao(BankDao bankDao) { this.bankDao = bankDao; } - + } diff --git a/samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security.xml b/samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security.xml index 7074675d1f..1a9a47abd7 100644 --- a/samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security.xml +++ b/samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security.xml @@ -1,62 +1,61 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/tutorial/src/main/webapp/WEB-INF/classes/log4j.properties b/samples/tutorial/src/main/webapp/WEB-INF/classes/log4j.properties index 396e59b4eb..b004df9646 100644 --- a/samples/tutorial/src/main/webapp/WEB-INF/classes/log4j.properties +++ b/samples/tutorial/src/main/webapp/WEB-INF/classes/log4j.properties @@ -1,16 +1,16 @@ -# Global logging configuration -log4j.rootLogger=DEBUG, stdout - -log4j.logger.org.springframework.security=DEBUG - -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.conversionPattern=[%p,%c{1}] %m%n - -# Rolling log file output... -log4j.appender.fileout=org.apache.log4j.FileAppender -log4j.appender.fileout.File=spring-security-tutorial.log -log4j.appender.fileout.layout=org.apache.log4j.PatternLayout -log4j.appender.fileout.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1},%t:%L - %m%n -log4j.appender.fileout.Append=false +# Global logging configuration +log4j.rootLogger=DEBUG, stdout + +log4j.logger.org.springframework.security=DEBUG + +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.conversionPattern=[%p,%c{1}] %m%n + +# Rolling log file output... +log4j.appender.fileout=org.apache.log4j.FileAppender +log4j.appender.fileout.File=spring-security-tutorial.log +log4j.appender.fileout.layout=org.apache.log4j.PatternLayout +log4j.appender.fileout.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1},%t:%L - %m%n +log4j.appender.fileout.Append=false diff --git a/samples/tutorial/src/main/webapp/WEB-INF/web.xml b/samples/tutorial/src/main/webapp/WEB-INF/web.xml index ecd1d922fe..ce19450d59 100644 --- a/samples/tutorial/src/main/webapp/WEB-INF/web.xml +++ b/samples/tutorial/src/main/webapp/WEB-INF/web.xml @@ -1,85 +1,84 @@ - - - - - - Spring Security Tutorial Application - - - - contextConfigLocation - - classpath:applicationContext-business.xml - /WEB-INF/applicationContext-security.xml - + + + + + + Spring Security Tutorial Application + + + + contextConfigLocation + + classpath:applicationContext-business.xml + /WEB-INF/applicationContext-security.xml + log4jConfigLocation /WEB-INF/classes/log4j.properties - - - - webAppRootKey - tutorial.root - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - - springSecurityFilterChain - /* - - - - - org.springframework.web.context.ContextLoaderListener - - - - - org.springframework.security.web.session.HttpSessionEventPublisher + + + + webAppRootKey + tutorial.root + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + + springSecurityFilterChain + /* + + + + + org.springframework.web.context.ContextLoaderListener + + + + + org.springframework.security.web.session.HttpSessionEventPublisher org.springframework.web.util.Log4jConfigListener - - - - - bank - org.springframework.web.servlet.DispatcherServlet - 1 - - - - bank - *.html - - - - index.jsp - - - + + + + + bank + org.springframework.web.servlet.DispatcherServlet + 1 + + + + bank + *.html + + + + index.jsp + + + diff --git a/samples/tutorial/src/main/webapp/index.jsp b/samples/tutorial/src/main/webapp/index.jsp index bd1690e57c..8c2e005bf9 100644 --- a/samples/tutorial/src/main/webapp/index.jsp +++ b/samples/tutorial/src/main/webapp/index.jsp @@ -1,25 +1,25 @@ -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> - - -

Home Page

-

-Anyone can view this page. -

-

-If you're logged in, you can list accounts. -

-

-Your principal object is....: <%= request.getUserPrincipal() %> -

-

-You can currently access "/secure" URLs. -

-

-You can currently access "/secure/extreme" URLs. -

- -

-Secure page

-

Extremely secure page

- - +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> + + +

Home Page

+

+Anyone can view this page. +

+

+If you're logged in, you can list accounts. +

+

+Your principal object is....: <%= request.getUserPrincipal() %> +

+

+You can currently access "/secure" URLs. +

+

+You can currently access "/secure/extreme" URLs. +

+ +

+Secure page

+

Extremely secure page

+ + diff --git a/samples/tutorial/src/main/webapp/secure/extreme/index.jsp b/samples/tutorial/src/main/webapp/secure/extreme/index.jsp index a629b69853..b796637af7 100644 --- a/samples/tutorial/src/main/webapp/secure/extreme/index.jsp +++ b/samples/tutorial/src/main/webapp/secure/extreme/index.jsp @@ -1,15 +1,15 @@ -<%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags" %> - - - -

VERY Secure Page

-This is a protected page. You can only see me if you are a supervisor. - - - You have "ROLE_SUPERVISOR" (this text is surrounded by <authz:authorize> tags). - - -

Home -

Logout - - +<%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags" %> + + + +

VERY Secure Page

+This is a protected page. You can only see me if you are a supervisor. + + + You have "ROLE_SUPERVISOR" (this text is surrounded by <authz:authorize> tags). + + +

Home +

Logout + + diff --git a/samples/tutorial/src/main/webapp/secure/index.jsp b/samples/tutorial/src/main/webapp/secure/index.jsp index 8fa5039644..95fca71f15 100644 --- a/samples/tutorial/src/main/webapp/secure/index.jsp +++ b/samples/tutorial/src/main/webapp/secure/index.jsp @@ -1,36 +1,36 @@ -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> - - - -

Secure Page

-

-This is a protected page. You can get to me if you've been remembered, -or if you've authenticated this session. -

- - - You are a supervisor! You can therefore see the extremely secure page.

-
- -

Properties obtained using <sec:authentication /> tag

- - - - - - - - - - - - - - -
TagValue
<sec:authentication property='name' />
<sec:authentication property='principal.username' />
<sec:authentication property='principal.enabled' />
<sec:authentication property='principal.accountNonLocked' />
- - -

Home -

Logout - - +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> + + + +

Secure Page

+

+This is a protected page. You can get to me if you've been remembered, +or if you've authenticated this session. +

+ + + You are a supervisor! You can therefore see the extremely secure page.

+
+ +

Properties obtained using <sec:authentication /> tag

+ + + + + + + + + + + + + + +
TagValue
<sec:authentication property='name' />
<sec:authentication property='principal.username' />
<sec:authentication property='principal.enabled' />
<sec:authentication property='principal.accountNonLocked' />
+ + +

Home +

Logout + + diff --git a/sandbox/heavyduty/jetty-jmx.xml b/sandbox/heavyduty/jetty-jmx.xml index 7a553731b8..53fe158000 100644 --- a/sandbox/heavyduty/jetty-jmx.xml +++ b/sandbox/heavyduty/jetty-jmx.xml @@ -16,14 +16,14 @@ - + - + @@ -36,8 +36,8 @@ - - - + diff --git a/sandbox/heavyduty/pom.xml b/sandbox/heavyduty/pom.xml index 94b2609313..bb4fdc6983 100755 --- a/sandbox/heavyduty/pom.xml +++ b/sandbox/heavyduty/pom.xml @@ -53,7 +53,7 @@ spring-orm ${spring.version} - + - + \ No newline at end of file diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-misc.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-misc.xml index b8c4466010..fe88354e47 100755 --- a/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-misc.xml +++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-misc.xml @@ -4,7 +4,6 @@ | | Miscellaneous beans added just to test configuration options | - | $Id$ --> - + @@ -47,20 +46,20 @@ My Realm - - - - - - - - bigbank.BankService.post*=ROLE_SUPERVISOR - bigbank.BankService.find*=ROLE_SUPERVISOR - - + + + + + + + + bigbank.BankService.post*=ROLE_SUPERVISOR + bigbank.BankService.find*=ROLE_SUPERVISOR + + - - \ No newline at end of file + + diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-persistence.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-persistence.xml index 48766f8881..84e67eb41d 100755 --- a/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-persistence.xml +++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-persistence.xml @@ -1,55 +1,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-security.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-security.xml index 511109a9ab..020f874cd6 100755 --- a/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-security.xml +++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-security.xml @@ -3,7 +3,6 @@ - - + + @@ -95,7 +94,7 @@ - + diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/applicationContext-acegi-security.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/applicationContext-acegi-security.xml index 3057ccc8ee..6170438f27 100755 --- a/sandbox/heavyduty/src/main/webapp/WEB-INF/applicationContext-acegi-security.xml +++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/applicationContext-acegi-security.xml @@ -13,7 +13,6 @@ - declared in the application context in the same order. Collaborators - required by those filters are placed at the end of the file. - - - $Id: applicationContext-acegi-security.xml 2366 2007-12-11 19:18:44Z benalex $ --> diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/META-INF/persistence.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/META-INF/persistence.xml index 20e12ff1bf..0940ec5720 100755 --- a/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/META-INF/persistence.xml +++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/META-INF/persistence.xml @@ -1,24 +1,24 @@ - - - - org.hibernate.ejb.HibernatePersistence - sample.domain.User - - - - - - - - - - - - + + + + org.hibernate.ejb.HibernatePersistence + sample.domain.User + + + + + + + + + + + + diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/jdbc.properties b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/jdbc.properties index 94b3759502..144ced8acf 100755 --- a/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/jdbc.properties +++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/jdbc.properties @@ -1,8 +1,8 @@ -jpa.dialect=org.hibernate.dialect.HSQLDialect -jpa.generateDdl=true -jpa.showSql=true - -jdbc.driver=org.hsqldb.jdbcDriver -jdbc.url=jdbc:hsqldb:mem:heavyduty -jdbc.username=sa +jpa.dialect=org.hibernate.dialect.HSQLDialect +jpa.generateDdl=true +jpa.showSql=true + +jdbc.driver=org.hsqldb.jdbcDriver +jdbc.url=jdbc:hsqldb:mem:heavyduty +jdbc.username=sa jdbc.password= \ No newline at end of file diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/log4j.properties b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/log4j.properties index 4859cd5307..2cfa73e4bc 100755 --- a/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/log4j.properties +++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/log4j.properties @@ -1,10 +1,10 @@ -# Global logging configuration -log4j.rootLogger=DEBUG, stdout - -log4j.logger.org.springframework.security=DEBUG -log4j.logger.org.apache.directory=INFO - -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.conversionPattern=[%p,%c{1},%L] - %m%n +# Global logging configuration +log4j.rootLogger=DEBUG, stdout + +log4j.logger.org.springframework.security=DEBUG +log4j.logger.org.apache.directory=INFO + +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.conversionPattern=[%p,%c{1},%L] - %m%n diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/heavyduty-servlet.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/heavyduty-servlet.xml index 21d064be35..4d46d8c5d7 100755 --- a/sandbox/heavyduty/src/main/webapp/WEB-INF/heavyduty-servlet.xml +++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/heavyduty-servlet.xml @@ -4,24 +4,24 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - - - - - - - - - - - - - - + + + + + + + + diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/web.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/web.xml index 9a678c7c27..731f474975 100755 --- a/sandbox/heavyduty/src/main/webapp/WEB-INF/web.xml +++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/web.xml @@ -1,86 +1,85 @@ - - - - - - Spring Security Tutorial Application - - - - contextConfigLocation - + + + + + + Spring Security Tutorial Application + + + + contextConfigLocation + classpath:applicationContext-business.xml - /WEB-INF/appContext-persistence.xml - /WEB-INF/appContext-security.xml - + /WEB-INF/appContext-persistence.xml + /WEB-INF/appContext-security.xml + log4jConfigLocation /WEB-INF/classes/log4j.properties - - - - webAppRootKey - heavyduty.root - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - - springSecurityFilterChain - /* - + + + + webAppRootKey + heavyduty.root + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + + springSecurityFilterChain + /* + org.springframework.web.util.Log4jConfigListener - - - - org.springframework.web.context.ContextLoaderListener - - - - - org.springframework.security.web.session.HttpSessionEventPublisher + + + + org.springframework.web.context.ContextLoaderListener - - - - heavyduty - org.springframework.web.servlet.DispatcherServlet - 1 - - - - heavyduty - *.htm - - - - index.jsp - - - + + + + org.springframework.security.web.session.HttpSessionEventPublisher + + + + + heavyduty + org.springframework.web.servlet.DispatcherServlet + 1 + + + + heavyduty + *.htm + + + + index.jsp + + + diff --git a/sandbox/heavyduty/src/main/webapp/index.jsp b/sandbox/heavyduty/src/main/webapp/index.jsp index 94a364172b..50ce9eec80 100755 --- a/sandbox/heavyduty/src/main/webapp/index.jsp +++ b/sandbox/heavyduty/src/main/webapp/index.jsp @@ -1,18 +1,18 @@ -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> - - -

HeavyDuty App Home Page

-

-Anyone can view this page. -

+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> + + +

HeavyDuty App Home Page

+

+Anyone can view this page. +

Test multi-action controller SEC-830. -

-

-Your principal object is....: <%= request.getUserPrincipal() %> -

-

Restricted Pages ...

-

Secure page

-

Extremely secure page

- +

+

+Your principal object is....: <%= request.getUserPrincipal() %> +

+

Restricted Pages ...

+

Secure page

+

Extremely secure page

+ \ No newline at end of file diff --git a/sandbox/heavyduty/src/main/webapp/secure/extreme/index.jsp b/sandbox/heavyduty/src/main/webapp/secure/extreme/index.jsp index 93f7a17cfc..f4e377dc50 100755 --- a/sandbox/heavyduty/src/main/webapp/secure/extreme/index.jsp +++ b/sandbox/heavyduty/src/main/webapp/secure/extreme/index.jsp @@ -1,15 +1,15 @@ -<%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags" %> - - - -

VERY Secure Page

-This is a protected page. You can only see me if you are a supervisor. - - - You have "ROLE_SUPERVISOR" (this text is surrounded by <authz:authorize> tags). - - -

Home -

Logout - +<%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags" %> + + + +

VERY Secure Page

+This is a protected page. You can only see me if you are a supervisor. + + + You have "ROLE_SUPERVISOR" (this text is surrounded by <authz:authorize> tags). + + +

Home +

Logout + \ No newline at end of file diff --git a/sandbox/heavyduty/src/main/webapp/secure/index.jsp b/sandbox/heavyduty/src/main/webapp/secure/index.jsp index 6abe155d88..ef87083a45 100755 --- a/sandbox/heavyduty/src/main/webapp/secure/index.jsp +++ b/sandbox/heavyduty/src/main/webapp/secure/index.jsp @@ -1,38 +1,38 @@ -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> - - - -

Secure Page

-

-This is a protected page. You can get to me if you've been remembered, -or if you've authenticated this session. -

- - - You are a supervisor! You can therefore see the extremely secure page.

-
- -

Properties obtained using <sec:authentication /> tag

- - - - - - - - - - - - - - +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> + + + +

Secure Page

+

+This is a protected page. You can get to me if you've been remembered, +or if you've authenticated this session. +

+ + + You are a supervisor! You can therefore see the extremely secure page.

+
+ +

Properties obtained using <sec:authentication /> tag

+
TagValue
<sec:authentication property='name' />
<sec:authentication property='principal.username' />
<sec:authentication property='principal.enabled' />
<sec:authentication property='principal.accountNonLocked' />
+ + + + + + + + + + + + +
TagValue
<sec:authentication property='name' />
<sec:authentication property='principal.username' />
<sec:authentication property='principal.enabled' />
<sec:authentication property='principal.accountNonLocked' />
-Saved Request: <%= session.getAttribute("SPRING_SECURITY_SAVED_REQUEST_KEY") %> - - -

Home -

Logout - +Saved Request: <%= session.getAttribute("SPRING_SECURITY_SAVED_REQUEST_KEY") %> + + +

Home +

Logout + \ No newline at end of file diff --git a/sandbox/webflow/pom.xml b/sandbox/webflow/pom.xml index 7893386193..2aefda7be4 100644 --- a/sandbox/webflow/pom.xml +++ b/sandbox/webflow/pom.xml @@ -24,27 +24,27 @@ ognl ognl - 2.7.3 - + 2.7.3 + org.springframework spring-web - 3.0.0.RELEASE + 3.0.0.RELEASE org.springframework spring-core - 3.0.0.RELEASE - + 3.0.0.RELEASE + org.springframework spring-context - 3.0.0.RELEASE - + 3.0.0.RELEASE + org.springframework spring-webmvc - 3.0.0.RELEASE + 3.0.0.RELEASE javax.servlet @@ -63,7 +63,7 @@ log4j runtime 1.2.14 - + diff --git a/sandbox/webflow/src/main/resources/applicationContext-business.xml b/sandbox/webflow/src/main/resources/applicationContext-business.xml index c67b41177a..f8d5228937 100644 --- a/sandbox/webflow/src/main/resources/applicationContext-business.xml +++ b/sandbox/webflow/src/main/resources/applicationContext-business.xml @@ -6,19 +6,19 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd"> - + - - - + + + - - + + - + \ No newline at end of file diff --git a/sandbox/webflow/src/main/webapp/WEB-INF/classes/log4j.properties b/sandbox/webflow/src/main/webapp/WEB-INF/classes/log4j.properties index 9300a2e82c..2837338900 100644 --- a/sandbox/webflow/src/main/webapp/WEB-INF/classes/log4j.properties +++ b/sandbox/webflow/src/main/webapp/WEB-INF/classes/log4j.properties @@ -1,18 +1,18 @@ -# Global logging configuration -log4j.rootLogger=DEBUG, stdout, fileout - -log4j.logger.org.springframework.security=DEBUG, stdout, fileout - -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.conversionPattern=[%p,%c{1},%t] %m%n - -# Rolling log file output... -log4j.appender.fileout=org.apache.log4j.RollingFileAppender -log4j.appender.fileout.File=spring-security-tutorial.log -#log4j.appender.fileout.File=${webapp.root}/WEB-INF/log4j.log -log4j.appender.fileout.MaxFileSize=1024KB -log4j.appender.fileout.MaxBackupIndex=1 -log4j.appender.fileout.layout=org.apache.log4j.PatternLayout -log4j.appender.fileout.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1},%t:%L - %m%n +# Global logging configuration +log4j.rootLogger=DEBUG, stdout, fileout + +log4j.logger.org.springframework.security=DEBUG, stdout, fileout + +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.conversionPattern=[%p,%c{1},%t] %m%n + +# Rolling log file output... +log4j.appender.fileout=org.apache.log4j.RollingFileAppender +log4j.appender.fileout.File=spring-security-tutorial.log +#log4j.appender.fileout.File=${webapp.root}/WEB-INF/log4j.log +log4j.appender.fileout.MaxFileSize=1024KB +log4j.appender.fileout.MaxBackupIndex=1 +log4j.appender.fileout.layout=org.apache.log4j.PatternLayout +log4j.appender.fileout.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1},%t:%L - %m%n diff --git a/sandbox/webflow/src/main/webapp/WEB-INF/secure.xml b/sandbox/webflow/src/main/webapp/WEB-INF/secure.xml index f9d626eab5..01586adf48 100644 --- a/sandbox/webflow/src/main/webapp/WEB-INF/secure.xml +++ b/sandbox/webflow/src/main/webapp/WEB-INF/secure.xml @@ -3,17 +3,17 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> - - - - - - - - - - - + + + + + + + + + + + + - \ No newline at end of file diff --git a/sandbox/webflow/src/main/webapp/WEB-INF/security-config.xml b/sandbox/webflow/src/main/webapp/WEB-INF/security-config.xml index 37d826cc92..e3e9a41433 100644 --- a/sandbox/webflow/src/main/webapp/WEB-INF/security-config.xml +++ b/sandbox/webflow/src/main/webapp/WEB-INF/security-config.xml @@ -8,29 +8,29 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.2.xsd"> - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/webflow/src/main/webapp/WEB-INF/web.xml b/sandbox/webflow/src/main/webapp/WEB-INF/web.xml index af16e5b0bb..02cf95a435 100644 --- a/sandbox/webflow/src/main/webapp/WEB-INF/web.xml +++ b/sandbox/webflow/src/main/webapp/WEB-INF/web.xml @@ -1,75 +1,74 @@ - - - - - - Spring Security Tutorial Application - - - - contextConfigLocation - - /WEB-INF/security-config.xml - - - - - log4jConfigLocation - /WEB-INF/classes/log4j.properties - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - - springSecurityFilterChain - /* - - - - - org.springframework.web.context.ContextLoaderListener - - - - - org.springframework.security.ui.session.HttpSessionEventPublisher - - - - org.springframework.web.util.Log4jConfigListener - - - - - webflow - org.springframework.web.servlet.DispatcherServlet - 1 - - - - webflow - /app/* - - - + + + + + + Spring Security Tutorial Application + + + + contextConfigLocation + + /WEB-INF/security-config.xml + + + + + log4jConfigLocation + /WEB-INF/classes/log4j.properties + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + + springSecurityFilterChain + /* + + + + + org.springframework.web.context.ContextLoaderListener + + + + + org.springframework.security.ui.session.HttpSessionEventPublisher + + + + org.springframework.web.util.Log4jConfigListener + + + + + webflow + org.springframework.web.servlet.DispatcherServlet + 1 + + + + webflow + /app/* + + + diff --git a/sandbox/webflow/src/main/webapp/WEB-INF/webflow-servlet.xml b/sandbox/webflow/src/main/webapp/WEB-INF/webflow-servlet.xml index 9f6a90ac6e..96a3c91682 100644 --- a/sandbox/webflow/src/main/webapp/WEB-INF/webflow-servlet.xml +++ b/sandbox/webflow/src/main/webapp/WEB-INF/webflow-servlet.xml @@ -9,51 +9,51 @@ http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd"> - - - - /secure=flowController - - - - - - + + + + /secure=flowController + + + + + + - - - + + + - - - - - - + + + + + + - - - - - - - - - - - - - - + + + + + + - - - + + + + - + + + + + + + + \ No newline at end of file diff --git a/sandbox/webflow/src/main/webapp/secure/extreme/index.jsp b/sandbox/webflow/src/main/webapp/secure/extreme/index.jsp index 93f7a17cfc..f4e377dc50 100644 --- a/sandbox/webflow/src/main/webapp/secure/extreme/index.jsp +++ b/sandbox/webflow/src/main/webapp/secure/extreme/index.jsp @@ -1,15 +1,15 @@ -<%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags" %> - - - -

VERY Secure Page

-This is a protected page. You can only see me if you are a supervisor. - - - You have "ROLE_SUPERVISOR" (this text is surrounded by <authz:authorize> tags). - - -

Home -

Logout - +<%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags" %> + + + +

VERY Secure Page

+This is a protected page. You can only see me if you are a supervisor. + + + You have "ROLE_SUPERVISOR" (this text is surrounded by <authz:authorize> tags). + + +

Home +

Logout + \ No newline at end of file diff --git a/sandbox/webflow/src/main/webapp/secure/index.jsp b/sandbox/webflow/src/main/webapp/secure/index.jsp index e44be8bcd7..873e2553b1 100644 --- a/sandbox/webflow/src/main/webapp/secure/index.jsp +++ b/sandbox/webflow/src/main/webapp/secure/index.jsp @@ -1,36 +1,36 @@ -<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> - - - -

Secure Page

-

-This is a protected page. You can get to me if you've been remembered, -or if you've authenticated this session. -

- - - You are a supervisor! You can therefore see the extremely secure page.

-
- -

Properties obtained using <sec:authentication /> tag

- - - - - - - - - - - - - - -
TagValue
<sec:authentication property='name' />
<sec:authentication property='principal.username' />
<sec:authentication property='principal.enabled' />
<sec:authentication property='principal.accountNonLocked' />
- - -

Home -

Logout - +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> + + + +

Secure Page

+

+This is a protected page. You can get to me if you've been remembered, +or if you've authenticated this session. +

+ + + You are a supervisor! You can therefore see the extremely secure page.

+
+ +

Properties obtained using <sec:authentication /> tag

+ + + + + + + + + + + + + + +
TagValue
<sec:authentication property='name' />
<sec:authentication property='principal.username' />
<sec:authentication property='principal.enabled' />
<sec:authentication property='principal.accountNonLocked' />
+ + +

Home +

Logout + \ No newline at end of file diff --git a/taglibs/pom.xml b/taglibs/pom.xml index 3f4327cadf..106600f322 100644 --- a/taglibs/pom.xml +++ b/taglibs/pom.xml @@ -51,5 +51,5 @@ com.springsource.bundlor.maven - + diff --git a/taglibs/src/main/java/org/springframework/security/taglibs/authz/AccessControlListTag.java b/taglibs/src/main/java/org/springframework/security/taglibs/authz/AccessControlListTag.java index d292bd2931..613ff108a1 100644 --- a/taglibs/src/main/java/org/springframework/security/taglibs/authz/AccessControlListTag.java +++ b/taglibs/src/main/java/org/springframework/security/taglibs/authz/AccessControlListTag.java @@ -66,7 +66,6 @@ import org.springframework.web.util.ExpressionEvaluationUtils; * implementations are found in the application context. * * @author Ben Alex - * @version $Id$ */ public class AccessControlListTag extends TagSupport { //~ Static fields/initializers ===================================================================================== diff --git a/taglibs/src/main/java/org/springframework/security/taglibs/authz/AuthenticationTag.java b/taglibs/src/main/java/org/springframework/security/taglibs/authz/AuthenticationTag.java index c17cdd4783..efe8f5ca3a 100644 --- a/taglibs/src/main/java/org/springframework/security/taglibs/authz/AuthenticationTag.java +++ b/taglibs/src/main/java/org/springframework/security/taglibs/authz/AuthenticationTag.java @@ -39,7 +39,6 @@ import javax.servlet.jsp.tagext.TagSupport; * Whilst JSPs can access the SecurityContext directly, this tag avoids handling null conditions. * * @author Thomas Champagne - * @version $Id$ */ public class AuthenticationTag extends TagSupport { diff --git a/taglibs/src/main/java/org/springframework/security/taglibs/authz/AuthorizeTag.java b/taglibs/src/main/java/org/springframework/security/taglibs/authz/AuthorizeTag.java index 23cca4684d..af28090178 100644 --- a/taglibs/src/main/java/org/springframework/security/taglibs/authz/AuthorizeTag.java +++ b/taglibs/src/main/java/org/springframework/security/taglibs/authz/AuthorizeTag.java @@ -29,7 +29,6 @@ import org.springframework.web.context.support.WebApplicationContextUtils; *

  • by evaluating the current user's right to access a particular URL (set using the "url" attribute).
  • * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class AuthorizeTag extends LegacyAuthorizeTag { diff --git a/taglibs/src/main/java/org/springframework/security/taglibs/authz/LegacyAuthorizeTag.java b/taglibs/src/main/java/org/springframework/security/taglibs/authz/LegacyAuthorizeTag.java index edd6810cb5..4f120c9bc0 100644 --- a/taglibs/src/main/java/org/springframework/security/taglibs/authz/LegacyAuthorizeTag.java +++ b/taglibs/src/main/java/org/springframework/security/taglibs/authz/LegacyAuthorizeTag.java @@ -37,7 +37,6 @@ import org.springframework.web.util.ExpressionEvaluationUtils; * are granted to the request's principal. * * @author Francois Beausoleil - * @version $Id$ */ public class LegacyAuthorizeTag extends TagSupport { //~ Instance fields ================================================================================================ diff --git a/taglibs/src/main/java/org/springframework/security/taglibs/velocity/Authz.java b/taglibs/src/main/java/org/springframework/security/taglibs/velocity/Authz.java index 7b35f3fe10..2f5da33b21 100644 --- a/taglibs/src/main/java/org/springframework/security/taglibs/velocity/Authz.java +++ b/taglibs/src/main/java/org/springframework/security/taglibs/velocity/Authz.java @@ -30,7 +30,6 @@ import org.springframework.context.ApplicationContext; * {@link AuthenticationTag}, {@link AclTag}, {@link LegacyAuthorizeTag} * * @author Wang Qi - * @version $Id$ */ public interface Authz { //~ Methods ======================================================================================================== diff --git a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AccessControlListTagTests.java b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AccessControlListTagTests.java index a704e34ff6..a081746d53 100644 --- a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AccessControlListTagTests.java +++ b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AccessControlListTagTests.java @@ -27,7 +27,6 @@ import org.springframework.web.context.WebApplicationContext; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ @SuppressWarnings("unchecked") diff --git a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthenticationTagTests.java b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthenticationTagTests.java index 12d82e142d..201a27ceb3 100644 --- a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthenticationTagTests.java +++ b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthenticationTagTests.java @@ -31,7 +31,6 @@ import org.springframework.security.core.userdetails.User; * Tests {@link AuthenticationTag}. * * @author Ben Alex - * @version $Id$ */ public class AuthenticationTagTests extends TestCase { //~ Instance fields ================================================================================================ diff --git a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagAttributeTests.java b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagAttributeTests.java index 6c67b53932..22c02f8b3b 100644 --- a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagAttributeTests.java +++ b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagAttributeTests.java @@ -32,7 +32,6 @@ import javax.servlet.jsp.tagext.Tag; * DOCUMENT ME! * * @author Francois Beausoleil - * @version $Id$ */ public class AuthorizeTagAttributeTests extends TestCase { //~ Instance fields ================================================================================================ diff --git a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagCustomGrantedAuthorityTests.java b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagCustomGrantedAuthorityTests.java index e86b4500ea..13c2950ebb 100644 --- a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagCustomGrantedAuthorityTests.java +++ b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagCustomGrantedAuthorityTests.java @@ -30,7 +30,6 @@ import javax.servlet.jsp.tagext.Tag; /** * * @author Francois Beausoleil - * @version $Id$ */ public class AuthorizeTagCustomGrantedAuthorityTests extends TestCase { //~ Instance fields ================================================================================================ diff --git a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagTests.java b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagTests.java index d022fb7464..226c023fb5 100644 --- a/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagTests.java +++ b/taglibs/src/test/java/org/springframework/security/taglibs/authz/AuthorizeTagTests.java @@ -39,7 +39,6 @@ import org.springframework.web.context.support.StaticWebApplicationContext; /** * @author Francois Beausoleil * @author Luke Taylor - * @version $Id$ */ public class AuthorizeTagTests { //~ Instance fields ================================================================================================ diff --git a/web/src/main/java/org/springframework/security/web/AuthenticationEntryPoint.java b/web/src/main/java/org/springframework/security/web/AuthenticationEntryPoint.java index 27b992d3ad..711b9fb70a 100644 --- a/web/src/main/java/org/springframework/security/web/AuthenticationEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/AuthenticationEntryPoint.java @@ -29,7 +29,6 @@ import javax.servlet.http.HttpServletResponse; * Used by {@link ExceptionTranslationFilter} to commence an authentication scheme. * * @author Ben Alex - * @version $Id$ */ public interface AuthenticationEntryPoint { //~ Methods ======================================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/DefaultRedirectStrategy.java b/web/src/main/java/org/springframework/security/web/DefaultRedirectStrategy.java index 5640b7dc78..42055203f4 100644 --- a/web/src/main/java/org/springframework/security/web/DefaultRedirectStrategy.java +++ b/web/src/main/java/org/springframework/security/web/DefaultRedirectStrategy.java @@ -12,7 +12,6 @@ import org.apache.commons.logging.LogFactory; * Simple implementation of RedirectStrategy which is the default used throughout the framework. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class DefaultRedirectStrategy implements RedirectStrategy { diff --git a/web/src/main/java/org/springframework/security/web/FilterChainProxy.java b/web/src/main/java/org/springframework/security/web/FilterChainProxy.java index b63e864b35..776fa183b7 100644 --- a/web/src/main/java/org/springframework/security/web/FilterChainProxy.java +++ b/web/src/main/java/org/springframework/security/web/FilterChainProxy.java @@ -102,7 +102,6 @@ import org.springframework.web.filter.GenericFilterBean; * @author Ben Alex * @author Luke Taylor * - * @version $Id$ */ public class FilterChainProxy extends GenericFilterBean { //~ Static fields/initializers ===================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/FilterInvocation.java b/web/src/main/java/org/springframework/security/web/FilterInvocation.java index 6d01c65e68..49cb8ede37 100644 --- a/web/src/main/java/org/springframework/security/web/FilterInvocation.java +++ b/web/src/main/java/org/springframework/security/web/FilterInvocation.java @@ -34,7 +34,6 @@ import javax.servlet.http.HttpServletResponse; * * @author Ben Alex * @author colin sampaleanu - * @version $Id$ */ public class FilterInvocation { //~ Instance fields ================================================================================================ diff --git a/web/src/main/java/org/springframework/security/web/PortMapper.java b/web/src/main/java/org/springframework/security/web/PortMapper.java index 0f36469670..e67c6c59cf 100644 --- a/web/src/main/java/org/springframework/security/web/PortMapper.java +++ b/web/src/main/java/org/springframework/security/web/PortMapper.java @@ -21,7 +21,6 @@ package org.springframework.security.web; * and vice versa. * * @author Ben Alex - * @version $Id$ */ public interface PortMapper { //~ Methods ======================================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/PortMapperImpl.java b/web/src/main/java/org/springframework/security/web/PortMapperImpl.java index 1cc9b557b6..5dd3a6ce88 100644 --- a/web/src/main/java/org/springframework/security/web/PortMapperImpl.java +++ b/web/src/main/java/org/springframework/security/web/PortMapperImpl.java @@ -30,7 +30,6 @@ import java.util.Map; * * @author Ben Alex * @author colin sampaleanu - * @version $Id$ */ public class PortMapperImpl implements PortMapper { //~ Instance fields ================================================================================================ diff --git a/web/src/main/java/org/springframework/security/web/PortResolver.java b/web/src/main/java/org/springframework/security/web/PortResolver.java index bc0d469627..1fe42ae2e8 100644 --- a/web/src/main/java/org/springframework/security/web/PortResolver.java +++ b/web/src/main/java/org/springframework/security/web/PortResolver.java @@ -30,7 +30,6 @@ import javax.servlet.ServletRequest; *

    * * @author Ben Alex - * @version $Id$ */ public interface PortResolver { //~ Methods ======================================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/PortResolverImpl.java b/web/src/main/java/org/springframework/security/web/PortResolverImpl.java index f3fa263d5c..15da2bce66 100644 --- a/web/src/main/java/org/springframework/security/web/PortResolverImpl.java +++ b/web/src/main/java/org/springframework/security/web/PortResolverImpl.java @@ -31,7 +31,6 @@ import javax.servlet.ServletRequest; * {@link PortMapper}. * * @author Ben Alex - * @version $Id$ */ public class PortResolverImpl implements PortResolver { //~ Instance fields ================================================================================================ diff --git a/web/src/main/java/org/springframework/security/web/RedirectStrategy.java b/web/src/main/java/org/springframework/security/web/RedirectStrategy.java index f68e0c7bbb..060eef786e 100644 --- a/web/src/main/java/org/springframework/security/web/RedirectStrategy.java +++ b/web/src/main/java/org/springframework/security/web/RedirectStrategy.java @@ -9,7 +9,6 @@ import javax.servlet.http.HttpServletResponse; * Encapsulates the redirection logic for all classes in the framework which perform redirects. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface RedirectStrategy { diff --git a/web/src/main/java/org/springframework/security/web/access/AccessDeniedHandler.java b/web/src/main/java/org/springframework/security/web/access/AccessDeniedHandler.java index 162d9a7efe..ef9db9f356 100644 --- a/web/src/main/java/org/springframework/security/web/access/AccessDeniedHandler.java +++ b/web/src/main/java/org/springframework/security/web/access/AccessDeniedHandler.java @@ -1,49 +1,48 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.web.access; - -import org.springframework.security.access.AccessDeniedException; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - - -/** - * Used by {@link ExceptionTranslationFilter} to handle an - * AccessDeniedException. - * - * @author Ben Alex - * @version $Id$ - */ -public interface AccessDeniedHandler { - //~ Methods ======================================================================================================== - - /** - * Handles an access denied failure. - * - * @param request that resulted in an AccessDeniedException - * @param response so that the user agent can be advised of the failure - * @param accessDeniedException that caused the invocation - * - * @throws IOException in the event of an IOException - * @throws ServletException in the event of a ServletException - */ - void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) - throws IOException, ServletException; -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.web.access; + +import org.springframework.security.access.AccessDeniedException; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + + +/** + * Used by {@link ExceptionTranslationFilter} to handle an + * AccessDeniedException. + * + * @author Ben Alex + */ +public interface AccessDeniedHandler { + //~ Methods ======================================================================================================== + + /** + * Handles an access denied failure. + * + * @param request that resulted in an AccessDeniedException + * @param response so that the user agent can be advised of the failure + * @param accessDeniedException that caused the invocation + * + * @throws IOException in the event of an IOException + * @throws ServletException in the event of a ServletException + */ + void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) + throws IOException, ServletException; +} diff --git a/web/src/main/java/org/springframework/security/web/access/AccessDeniedHandlerImpl.java b/web/src/main/java/org/springframework/security/web/access/AccessDeniedHandlerImpl.java index d5cff8a3be..5bdf4547f1 100644 --- a/web/src/main/java/org/springframework/security/web/access/AccessDeniedHandlerImpl.java +++ b/web/src/main/java/org/springframework/security/web/access/AccessDeniedHandlerImpl.java @@ -1,88 +1,87 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.web.access; - -import java.io.IOException; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.security.access.AccessDeniedException; - - -/** - * Base implementation of {@link AccessDeniedHandler}. - *

    - * This implementation sends a 403 (SC_FORBIDDEN) HTTP error code. In addition, if an {@link #errorPage} is defined, - * the implementation will perform a request dispatcher "forward" to the specified error page view. - * Being a "forward", the SecurityContextHolder will remain - * populated. This is of benefit if the view (or a tag library or macro) wishes to access the - * SecurityContextHolder. The request scope will also be populated with the exception itself, available - * from the key {@link #SPRING_SECURITY_ACCESS_DENIED_EXCEPTION_KEY}. - * - * @author Ben Alex - * @version $Id$ - */ -public class AccessDeniedHandlerImpl implements AccessDeniedHandler { - //~ Static fields/initializers ===================================================================================== - - public static final String SPRING_SECURITY_ACCESS_DENIED_EXCEPTION_KEY = "SPRING_SECURITY_403_EXCEPTION"; - protected static final Log logger = LogFactory.getLog(AccessDeniedHandlerImpl.class); - - //~ Instance fields ================================================================================================ - - private String errorPage; - - //~ Methods ======================================================================================================== - - public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) - throws IOException, ServletException { - if (!response.isCommitted()) { - if (errorPage != null) { - // Put exception into request scope (perhaps of use to a view) - request.setAttribute(SPRING_SECURITY_ACCESS_DENIED_EXCEPTION_KEY, accessDeniedException); - - // Set the 403 status code. - response.setStatus(HttpServletResponse.SC_FORBIDDEN); - - // forward to error page. - RequestDispatcher dispatcher = request.getRequestDispatcher(errorPage); - dispatcher.forward(request, response); - } else { - response.sendError(HttpServletResponse.SC_FORBIDDEN, accessDeniedException.getMessage()); - } - } - } - - /** - * The error page to use. Must begin with a "/" and is interpreted relative to the current context root. - * - * @param errorPage the dispatcher path to display - * - * @throws IllegalArgumentException if the argument doesn't comply with the above limitations - */ - public void setErrorPage(String errorPage) { - if ((errorPage != null) && !errorPage.startsWith("/")) { - throw new IllegalArgumentException("errorPage must begin with '/'"); - } - - this.errorPage = errorPage; - } -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.web.access; + +import java.io.IOException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.security.access.AccessDeniedException; + + +/** + * Base implementation of {@link AccessDeniedHandler}. + *

    + * This implementation sends a 403 (SC_FORBIDDEN) HTTP error code. In addition, if an {@link #errorPage} is defined, + * the implementation will perform a request dispatcher "forward" to the specified error page view. + * Being a "forward", the SecurityContextHolder will remain + * populated. This is of benefit if the view (or a tag library or macro) wishes to access the + * SecurityContextHolder. The request scope will also be populated with the exception itself, available + * from the key {@link #SPRING_SECURITY_ACCESS_DENIED_EXCEPTION_KEY}. + * + * @author Ben Alex + */ +public class AccessDeniedHandlerImpl implements AccessDeniedHandler { + //~ Static fields/initializers ===================================================================================== + + public static final String SPRING_SECURITY_ACCESS_DENIED_EXCEPTION_KEY = "SPRING_SECURITY_403_EXCEPTION"; + protected static final Log logger = LogFactory.getLog(AccessDeniedHandlerImpl.class); + + //~ Instance fields ================================================================================================ + + private String errorPage; + + //~ Methods ======================================================================================================== + + public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) + throws IOException, ServletException { + if (!response.isCommitted()) { + if (errorPage != null) { + // Put exception into request scope (perhaps of use to a view) + request.setAttribute(SPRING_SECURITY_ACCESS_DENIED_EXCEPTION_KEY, accessDeniedException); + + // Set the 403 status code. + response.setStatus(HttpServletResponse.SC_FORBIDDEN); + + // forward to error page. + RequestDispatcher dispatcher = request.getRequestDispatcher(errorPage); + dispatcher.forward(request, response); + } else { + response.sendError(HttpServletResponse.SC_FORBIDDEN, accessDeniedException.getMessage()); + } + } + } + + /** + * The error page to use. Must begin with a "/" and is interpreted relative to the current context root. + * + * @param errorPage the dispatcher path to display + * + * @throws IllegalArgumentException if the argument doesn't comply with the above limitations + */ + public void setErrorPage(String errorPage) { + if ((errorPage != null) && !errorPage.startsWith("/")) { + throw new IllegalArgumentException("errorPage must begin with '/'"); + } + + this.errorPage = errorPage; + } +} diff --git a/web/src/main/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluator.java b/web/src/main/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluator.java index b2919908b0..66fa524146 100644 --- a/web/src/main/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluator.java +++ b/web/src/main/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluator.java @@ -52,7 +52,6 @@ import org.springframework.util.Assert; * * @author Ben Alex * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class DefaultWebInvocationPrivilegeEvaluator implements WebInvocationPrivilegeEvaluator { diff --git a/web/src/main/java/org/springframework/security/web/access/ExceptionTranslationFilter.java b/web/src/main/java/org/springframework/security/web/access/ExceptionTranslationFilter.java index 5e71abada3..11f0c1f2b8 100644 --- a/web/src/main/java/org/springframework/security/web/access/ExceptionTranslationFilter.java +++ b/web/src/main/java/org/springframework/security/web/access/ExceptionTranslationFilter.java @@ -67,7 +67,6 @@ import org.springframework.web.filter.GenericFilterBean; * * @author Ben Alex * @author colin sampaleanu - * @version $Id$ */ public class ExceptionTranslationFilter extends GenericFilterBean { diff --git a/web/src/main/java/org/springframework/security/web/access/channel/AbstractRetryEntryPoint.java b/web/src/main/java/org/springframework/security/web/access/channel/AbstractRetryEntryPoint.java index 8ec3292075..c50a8edca8 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/AbstractRetryEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/AbstractRetryEntryPoint.java @@ -16,7 +16,6 @@ import java.io.IOException; /** * @author Luke Taylor - * @version $Id$ */ public abstract class AbstractRetryEntryPoint implements ChannelEntryPoint { //~ Static fields/initializers ===================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/access/channel/ChannelDecisionManager.java b/web/src/main/java/org/springframework/security/web/access/channel/ChannelDecisionManager.java index 887069b4ae..e6d74ee484 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/ChannelDecisionManager.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/ChannelDecisionManager.java @@ -28,7 +28,6 @@ import javax.servlet.ServletException; * Decides whether a web channel provides sufficient security. * * @author Ben Alex - * @version $Id$ */ public interface ChannelDecisionManager { //~ Methods ======================================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImpl.java b/web/src/main/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImpl.java index b21fbfb044..5652587ec1 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImpl.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImpl.java @@ -46,7 +46,6 @@ import javax.servlet.ServletException; * skipped (see SEC-494, SEC-335). * * @author Ben Alex - * @version $Id$ */ public class ChannelDecisionManagerImpl implements ChannelDecisionManager, InitializingBean { diff --git a/web/src/main/java/org/springframework/security/web/access/channel/ChannelEntryPoint.java b/web/src/main/java/org/springframework/security/web/access/channel/ChannelEntryPoint.java index 41a7ddcd54..5a93e28d13 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/ChannelEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/ChannelEntryPoint.java @@ -31,7 +31,6 @@ import javax.servlet.http.HttpServletResponse; * this delegation. * * @author Ben Alex - * @version $Id$ */ public interface ChannelEntryPoint { //~ Methods ======================================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/access/channel/ChannelProcessingFilter.java b/web/src/main/java/org/springframework/security/web/access/channel/ChannelProcessingFilter.java index 782da57496..98330c21bb 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/ChannelProcessingFilter.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/ChannelProcessingFilter.java @@ -43,7 +43,6 @@ import org.springframework.web.filter.GenericFilterBean; * the filter chain will not proceed.

    * * @author Ben Alex - * @version $Id$ */ public class ChannelProcessingFilter extends GenericFilterBean { diff --git a/web/src/main/java/org/springframework/security/web/access/channel/ChannelProcessor.java b/web/src/main/java/org/springframework/security/web/access/channel/ChannelProcessor.java index b4340b4235..2038ff4058 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/ChannelProcessor.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/ChannelProcessor.java @@ -34,7 +34,6 @@ import javax.servlet.ServletException; * action. * * @author Ben Alex - * @version $Id$ */ public interface ChannelProcessor { //~ Methods ======================================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/access/channel/InsecureChannelProcessor.java b/web/src/main/java/org/springframework/security/web/access/channel/InsecureChannelProcessor.java index e385fbf78d..32da4bf7cf 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/InsecureChannelProcessor.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/InsecureChannelProcessor.java @@ -37,7 +37,6 @@ import org.springframework.util.Assert; * The default insecureKeyword is REQUIRES_INSECURE_CHANNEL. * * @author Ben Alex - * @version $Id$ */ public class InsecureChannelProcessor implements InitializingBean, ChannelProcessor { //~ Instance fields ================================================================================================ diff --git a/web/src/main/java/org/springframework/security/web/access/channel/RetryWithHttpEntryPoint.java b/web/src/main/java/org/springframework/security/web/access/channel/RetryWithHttpEntryPoint.java index f1fbed5ea2..3375d94ded 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/RetryWithHttpEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/RetryWithHttpEntryPoint.java @@ -23,7 +23,6 @@ package org.springframework.security.web.access.channel; * other usage where a standard redirect would cause an issue. * * @author Ben Alex - * @version $Id$ */ public class RetryWithHttpEntryPoint extends AbstractRetryEntryPoint { diff --git a/web/src/main/java/org/springframework/security/web/access/channel/RetryWithHttpsEntryPoint.java b/web/src/main/java/org/springframework/security/web/access/channel/RetryWithHttpsEntryPoint.java index e11a07b010..11b11f6883 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/RetryWithHttpsEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/RetryWithHttpsEntryPoint.java @@ -22,7 +22,6 @@ package org.springframework.security.web.access.channel; * or other usage where a standard redirect would cause an issue.

    * * @author Ben Alex - * @version $Id$ */ public class RetryWithHttpsEntryPoint extends AbstractRetryEntryPoint { diff --git a/web/src/main/java/org/springframework/security/web/access/channel/SecureChannelProcessor.java b/web/src/main/java/org/springframework/security/web/access/channel/SecureChannelProcessor.java index b2a4aa5704..fe284b3a60 100644 --- a/web/src/main/java/org/springframework/security/web/access/channel/SecureChannelProcessor.java +++ b/web/src/main/java/org/springframework/security/web/access/channel/SecureChannelProcessor.java @@ -37,7 +37,6 @@ import org.springframework.util.Assert; * The default secureKeyword is REQUIRES_SECURE_CHANNEL. * * @author Ben Alex - * @version $Id$ */ public class SecureChannelProcessor implements InitializingBean, ChannelProcessor { //~ Instance fields ================================================================================================ diff --git a/web/src/main/java/org/springframework/security/web/access/expression/DefaultWebSecurityExpressionHandler.java b/web/src/main/java/org/springframework/security/web/access/expression/DefaultWebSecurityExpressionHandler.java index 2fea10df66..11236a96a9 100644 --- a/web/src/main/java/org/springframework/security/web/access/expression/DefaultWebSecurityExpressionHandler.java +++ b/web/src/main/java/org/springframework/security/web/access/expression/DefaultWebSecurityExpressionHandler.java @@ -16,7 +16,6 @@ import org.springframework.security.web.FilterInvocation; * from the implementation of the underlying expression objects. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class DefaultWebSecurityExpressionHandler implements WebSecurityExpressionHandler { diff --git a/web/src/main/java/org/springframework/security/web/access/expression/ExpressionBasedFilterInvocationSecurityMetadataSource.java b/web/src/main/java/org/springframework/security/web/access/expression/ExpressionBasedFilterInvocationSecurityMetadataSource.java index 72b9117a66..6686c89693 100644 --- a/web/src/main/java/org/springframework/security/web/access/expression/ExpressionBasedFilterInvocationSecurityMetadataSource.java +++ b/web/src/main/java/org/springframework/security/web/access/expression/ExpressionBasedFilterInvocationSecurityMetadataSource.java @@ -19,7 +19,6 @@ import org.springframework.util.Assert; * Expression-based FilterInvocationSecurityMetadataSource. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public final class ExpressionBasedFilterInvocationSecurityMetadataSource extends DefaultFilterInvocationSecurityMetadataSource { diff --git a/web/src/main/java/org/springframework/security/web/access/expression/WebExpressionConfigAttribute.java b/web/src/main/java/org/springframework/security/web/access/expression/WebExpressionConfigAttribute.java index e950338f97..6834a56479 100644 --- a/web/src/main/java/org/springframework/security/web/access/expression/WebExpressionConfigAttribute.java +++ b/web/src/main/java/org/springframework/security/web/access/expression/WebExpressionConfigAttribute.java @@ -7,7 +7,6 @@ import org.springframework.security.access.ConfigAttribute; * Simple expression configuration attribute for use in web request authorizations. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ class WebExpressionConfigAttribute implements ConfigAttribute { diff --git a/web/src/main/java/org/springframework/security/web/access/expression/WebExpressionVoter.java b/web/src/main/java/org/springframework/security/web/access/expression/WebExpressionVoter.java index 9df1fdc3d4..439c1fccf0 100644 --- a/web/src/main/java/org/springframework/security/web/access/expression/WebExpressionVoter.java +++ b/web/src/main/java/org/springframework/security/web/access/expression/WebExpressionVoter.java @@ -12,7 +12,6 @@ import org.springframework.security.web.FilterInvocation; /** * Voter which handles web authorisation decisions. * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class WebExpressionVoter implements AccessDecisionVoter { diff --git a/web/src/main/java/org/springframework/security/web/access/expression/WebSecurityExpressionRoot.java b/web/src/main/java/org/springframework/security/web/access/expression/WebSecurityExpressionRoot.java index 2d8f2f05b2..3580cf182e 100644 --- a/web/src/main/java/org/springframework/security/web/access/expression/WebSecurityExpressionRoot.java +++ b/web/src/main/java/org/springframework/security/web/access/expression/WebSecurityExpressionRoot.java @@ -14,7 +14,6 @@ import org.springframework.util.StringUtils; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class WebSecurityExpressionRoot extends SecurityExpressionRoot { diff --git a/web/src/main/java/org/springframework/security/web/access/intercept/DefaultFilterInvocationSecurityMetadataSource.java b/web/src/main/java/org/springframework/security/web/access/intercept/DefaultFilterInvocationSecurityMetadataSource.java index 4fb4e1b769..f65475c998 100644 --- a/web/src/main/java/org/springframework/security/web/access/intercept/DefaultFilterInvocationSecurityMetadataSource.java +++ b/web/src/main/java/org/springframework/security/web/access/intercept/DefaultFilterInvocationSecurityMetadataSource.java @@ -49,7 +49,6 @@ import org.springframework.security.web.util.UrlMatcher; * * @author Ben Alex * @author Luke Taylor - * @version $Id$ */ public class DefaultFilterInvocationSecurityMetadataSource implements FilterInvocationSecurityMetadataSource { diff --git a/web/src/main/java/org/springframework/security/web/access/intercept/FilterInvocationSecurityMetadataSource.java b/web/src/main/java/org/springframework/security/web/access/intercept/FilterInvocationSecurityMetadataSource.java index b3fb6609ce..b6f4145812 100644 --- a/web/src/main/java/org/springframework/security/web/access/intercept/FilterInvocationSecurityMetadataSource.java +++ b/web/src/main/java/org/springframework/security/web/access/intercept/FilterInvocationSecurityMetadataSource.java @@ -24,6 +24,5 @@ import org.springframework.security.web.FilterInvocation; * that are designed to perform lookups keyed on {@link FilterInvocation}s. * * @author Ben Alex - * @version $Id$ */ public interface FilterInvocationSecurityMetadataSource extends SecurityMetadataSource {} diff --git a/web/src/main/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptor.java b/web/src/main/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptor.java index f8ed6a0bd0..139549ee0a 100644 --- a/web/src/main/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptor.java +++ b/web/src/main/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptor.java @@ -39,7 +39,6 @@ import org.springframework.security.web.FilterInvocation; * Refer to {@link AbstractSecurityInterceptor} for details on the workflow.

    * * @author Ben Alex - * @version $Id$ */ public class FilterSecurityInterceptor extends AbstractSecurityInterceptor implements Filter { //~ Static fields/initializers ===================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/access/intercept/RequestKey.java b/web/src/main/java/org/springframework/security/web/access/intercept/RequestKey.java index 70fcaa3dda..3c699f4e08 100644 --- a/web/src/main/java/org/springframework/security/web/access/intercept/RequestKey.java +++ b/web/src/main/java/org/springframework/security/web/access/intercept/RequestKey.java @@ -2,7 +2,6 @@ package org.springframework.security.web.access.intercept; /** * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public class RequestKey { @@ -17,7 +16,7 @@ public class RequestKey { this.url = url; this.method = method; } - + String getUrl() { return url; } @@ -29,7 +28,7 @@ public class RequestKey { public int hashCode() { int code = 31; code ^= url.hashCode(); - + if (method != null) { code ^= method.hashCode(); } @@ -47,12 +46,12 @@ public class RequestKey { if (!url.equals(key.url)) { return false; } - + if (method == null) { return key.method == null; } - return method.equals(key.method); + return method.equals(key.method); } public String toString() { @@ -63,7 +62,7 @@ public class RequestKey { } sb.append(url); sb.append("]"); - + return sb.toString(); } } diff --git a/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.java b/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.java index 153b3372e8..b6dc548991 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.java @@ -101,7 +101,6 @@ import org.springframework.web.filter.GenericFilterBean; * sessionRegistry property to make sure that the session information is updated consistently. * * @author Ben Alex - * @version $Id$ */ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilterBean implements ApplicationEventPublisherAware, MessageSourceAware { @@ -394,7 +393,7 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt /** * The session handling strategy which will be invoked immediately after an authentication request is - * successfully processed by the AuthenticationManager. Used, for example, to handle changing of the + * successfully processed by the AuthenticationManager. Used, for example, to handle changing of the * session identifier to prevent session fixation attacks. * * @param sessionStrategy the implementation to use. If not set a null implementation is diff --git a/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationTargetUrlRequestHandler.java b/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationTargetUrlRequestHandler.java index afe3d1bc89..630d6a2895 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationTargetUrlRequestHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationTargetUrlRequestHandler.java @@ -41,7 +41,6 @@ import org.springframework.util.StringUtils; * * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public abstract class AbstractAuthenticationTargetUrlRequestHandler { diff --git a/web/src/main/java/org/springframework/security/web/authentication/AbstractProcessingFilter.java b/web/src/main/java/org/springframework/security/web/authentication/AbstractProcessingFilter.java index 4bbfd58dee..b75cb7a108 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/AbstractProcessingFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/AbstractProcessingFilter.java @@ -6,7 +6,6 @@ package org.springframework.security.web.authentication; * See {@link AbstractAuthenticationProcessingFilter}. * * @author Luke Taylor - * @version $Id$ * @deprecated Use AbstractAuthenticationProcessingFilter instead. */ @Deprecated diff --git a/web/src/main/java/org/springframework/security/web/authentication/AnonymousAuthenticationFilter.java b/web/src/main/java/org/springframework/security/web/authentication/AnonymousAuthenticationFilter.java index c0049e5fd6..d5cfd1dec4 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/AnonymousAuthenticationFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/AnonymousAuthenticationFilter.java @@ -39,7 +39,6 @@ import org.springframework.web.filter.GenericFilterBean; * populates it with one if needed. * * @author Ben Alex - * @version $Id$ */ public class AnonymousAuthenticationFilter extends GenericFilterBean implements InitializingBean { diff --git a/web/src/main/java/org/springframework/security/web/authentication/AuthenticationFailureHandler.java b/web/src/main/java/org/springframework/security/web/authentication/AuthenticationFailureHandler.java index c4c307132f..72a84d4a81 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/AuthenticationFailureHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/AuthenticationFailureHandler.java @@ -18,7 +18,6 @@ import org.springframework.security.core.AuthenticationException; * user to change their password. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface AuthenticationFailureHandler { diff --git a/web/src/main/java/org/springframework/security/web/authentication/AuthenticationProcessingFilter.java b/web/src/main/java/org/springframework/security/web/authentication/AuthenticationProcessingFilter.java index 78e2341f68..06dcd8bca0 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/AuthenticationProcessingFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/AuthenticationProcessingFilter.java @@ -6,7 +6,6 @@ package org.springframework.security.web.authentication; * See {@link UsernamePasswordAuthenticationFilter}. * * @author Luke Taylor - * @version $Id$ * @deprecated Use UsernamePasswordAuthenticationFilter instead. */ diff --git a/web/src/main/java/org/springframework/security/web/authentication/AuthenticationProcessingFilterEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/AuthenticationProcessingFilterEntryPoint.java index be8c4d5f4a..02bc133d76 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/AuthenticationProcessingFilterEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/AuthenticationProcessingFilterEntryPoint.java @@ -6,7 +6,6 @@ package org.springframework.security.web.authentication; * See {@link LoginUrlAuthenticationEntryPoint}. * * @author Luke Taylor - * @version $Id$ * @deprecated Use LoginUrlAuthenticationEntryPoint instead. */ public class AuthenticationProcessingFilterEntryPoint extends LoginUrlAuthenticationEntryPoint{ diff --git a/web/src/main/java/org/springframework/security/web/authentication/AuthenticationSuccessHandler.java b/web/src/main/java/org/springframework/security/web/authentication/AuthenticationSuccessHandler.java index 754ac612ac..ff71df2c80 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/AuthenticationSuccessHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/AuthenticationSuccessHandler.java @@ -17,7 +17,6 @@ import org.springframework.security.core.Authentication; * (see {@link AbstractAuthenticationProcessingFilter} and subclasses). Other logic may also be included if required. * * @author Luke Taylor - * @version $Id$ * @since 3.0 * @see */ diff --git a/web/src/main/java/org/springframework/security/web/authentication/ExceptionMappingAuthenticationFailureHandler.java b/web/src/main/java/org/springframework/security/web/authentication/ExceptionMappingAuthenticationFailureHandler.java index 311b76baef..7d3ece9a12 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/ExceptionMappingAuthenticationFailureHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/ExceptionMappingAuthenticationFailureHandler.java @@ -22,7 +22,6 @@ import org.springframework.util.Assert; * The map of exception names to URLs should be injected by setting the exceptionMappings property. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class ExceptionMappingAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler { diff --git a/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java index 29a037de8f..f8c4b03fe3 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java @@ -59,7 +59,6 @@ import org.springframework.util.StringUtils; * @author colin sampaleanu * @author Omri Spector * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoint, InitializingBean { diff --git a/web/src/main/java/org/springframework/security/web/authentication/NullRememberMeServices.java b/web/src/main/java/org/springframework/security/web/authentication/NullRememberMeServices.java index 5e9722c7c6..bf48e6e25c 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/NullRememberMeServices.java +++ b/web/src/main/java/org/springframework/security/web/authentication/NullRememberMeServices.java @@ -26,7 +26,6 @@ import javax.servlet.http.HttpServletResponse; * classes.

    * * @author Ben Alex - * @version $Id$ */ public class NullRememberMeServices implements RememberMeServices { //~ Methods ======================================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/authentication/RememberMeServices.java b/web/src/main/java/org/springframework/security/web/authentication/RememberMeServices.java index 5b1661fdd3..cee2631601 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/RememberMeServices.java +++ b/web/src/main/java/org/springframework/security/web/authentication/RememberMeServices.java @@ -39,7 +39,6 @@ import org.springframework.security.core.Authentication; * capability, as this will be implementation specific and requires no hooks into Spring Security. * * @author Ben Alex - * @version $Id$ */ public interface RememberMeServices { //~ Methods ======================================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/authentication/SavedRequestAwareAuthenticationSuccessHandler.java b/web/src/main/java/org/springframework/security/web/authentication/SavedRequestAwareAuthenticationSuccessHandler.java index 604d51a2f2..f578ead0b1 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/SavedRequestAwareAuthenticationSuccessHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/SavedRequestAwareAuthenticationSuccessHandler.java @@ -47,7 +47,6 @@ import org.springframework.util.StringUtils; * * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class SavedRequestAwareAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler { diff --git a/web/src/main/java/org/springframework/security/web/authentication/SimpleUrlAuthenticationFailureHandler.java b/web/src/main/java/org/springframework/security/web/authentication/SimpleUrlAuthenticationFailureHandler.java index 022f2937e6..573137add2 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/SimpleUrlAuthenticationFailureHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/SimpleUrlAuthenticationFailureHandler.java @@ -24,7 +24,6 @@ import org.springframework.util.Assert; * the destination instead of a redirect. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class SimpleUrlAuthenticationFailureHandler implements AuthenticationFailureHandler { diff --git a/web/src/main/java/org/springframework/security/web/authentication/SimpleUrlAuthenticationSuccessHandler.java b/web/src/main/java/org/springframework/security/web/authentication/SimpleUrlAuthenticationSuccessHandler.java index 3cafe6af77..05e91eaa01 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/SimpleUrlAuthenticationSuccessHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/SimpleUrlAuthenticationSuccessHandler.java @@ -15,7 +15,6 @@ import org.springframework.security.core.Authentication; * The logic used is that of the {@link AbstractAuthenticationTargetUrlRequestHandler parent class}. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class SimpleUrlAuthenticationSuccessHandler extends AbstractAuthenticationTargetUrlRequestHandler implements AuthenticationSuccessHandler { diff --git a/web/src/main/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilter.java b/web/src/main/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilter.java index 7639a64739..474e563f5e 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilter.java @@ -43,7 +43,6 @@ import org.springframework.util.Assert; * @author Ben Alex * @author Colin Sampaleanu * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class UsernamePasswordAuthenticationFilter extends AbstractAuthenticationProcessingFilter { diff --git a/web/src/main/java/org/springframework/security/web/authentication/WebAuthenticationDetails.java b/web/src/main/java/org/springframework/security/web/authentication/WebAuthenticationDetails.java index 126eaefabb..7572e65d7c 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/WebAuthenticationDetails.java +++ b/web/src/main/java/org/springframework/security/web/authentication/WebAuthenticationDetails.java @@ -27,7 +27,6 @@ import javax.servlet.http.HttpSession; * A holder of selected HTTP details related to a web authentication request. * * @author Ben Alex - * @version $Id$ */ public class WebAuthenticationDetails implements SessionIdentifierAware, Serializable { //~ Instance fields ================================================================================================ diff --git a/web/src/main/java/org/springframework/security/web/authentication/WebAuthenticationDetailsSource.java b/web/src/main/java/org/springframework/security/web/authentication/WebAuthenticationDetailsSource.java index 8d9b363fc3..a538a51d1d 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/WebAuthenticationDetailsSource.java +++ b/web/src/main/java/org/springframework/security/web/authentication/WebAuthenticationDetailsSource.java @@ -1,71 +1,70 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.web.authentication; - -import org.springframework.security.authentication.AuthenticationDetailsSource; -import org.springframework.util.Assert; -import org.springframework.util.ReflectionUtils; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import javax.servlet.http.HttpServletRequest; - - -/** - * Implementation of {@link AuthenticationDetailsSource} which builds the details object from - * an HttpServletRequest object. - *

    - * By default will create an instance of WebAuthenticationDetails. Any object that accepts a - * HttpServletRequest as its sole constructor can be used instead of this default. - * - * @author Ben Alex - * @version $Id$ - */ -public class WebAuthenticationDetailsSource implements AuthenticationDetailsSource { - //~ Instance fields ================================================================================================ - - private Class clazz = WebAuthenticationDetails.class; - - //~ Methods ======================================================================================================== - - /** - * @param context the HttpServletRequest object. - */ - public Object buildDetails(Object context) { - Assert.isInstanceOf(HttpServletRequest.class, context); - try { - Constructor constructor = clazz.getConstructor(HttpServletRequest.class); - - return constructor.newInstance(context); - } catch (NoSuchMethodException ex) { - ReflectionUtils.handleReflectionException(ex); - } catch (InvocationTargetException ex) { - ReflectionUtils.handleReflectionException(ex); - } catch (InstantiationException ex) { - ReflectionUtils.handleReflectionException(ex); - } catch (IllegalAccessException ex) { - ReflectionUtils.handleReflectionException(ex); - } - - return null; - } - - public void setClazz(Class clazz) { - Assert.notNull(clazz, "Class required"); - this.clazz = clazz; - } -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.web.authentication; + +import org.springframework.security.authentication.AuthenticationDetailsSource; +import org.springframework.util.Assert; +import org.springframework.util.ReflectionUtils; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +import javax.servlet.http.HttpServletRequest; + + +/** + * Implementation of {@link AuthenticationDetailsSource} which builds the details object from + * an HttpServletRequest object. + *

    + * By default will create an instance of WebAuthenticationDetails. Any object that accepts a + * HttpServletRequest as its sole constructor can be used instead of this default. + * + * @author Ben Alex + */ +public class WebAuthenticationDetailsSource implements AuthenticationDetailsSource { + //~ Instance fields ================================================================================================ + + private Class clazz = WebAuthenticationDetails.class; + + //~ Methods ======================================================================================================== + + /** + * @param context the HttpServletRequest object. + */ + public Object buildDetails(Object context) { + Assert.isInstanceOf(HttpServletRequest.class, context); + try { + Constructor constructor = clazz.getConstructor(HttpServletRequest.class); + + return constructor.newInstance(context); + } catch (NoSuchMethodException ex) { + ReflectionUtils.handleReflectionException(ex); + } catch (InvocationTargetException ex) { + ReflectionUtils.handleReflectionException(ex); + } catch (InstantiationException ex) { + ReflectionUtils.handleReflectionException(ex); + } catch (IllegalAccessException ex) { + ReflectionUtils.handleReflectionException(ex); + } + + return null; + } + + public void setClazz(Class clazz) { + Assert.notNull(clazz, "Class required"); + this.clazz = clazz; + } +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/logout/LogoutFilter.java b/web/src/main/java/org/springframework/security/web/authentication/logout/LogoutFilter.java index 7de32e3b17..1ca909369b 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/logout/LogoutFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/logout/LogoutFilter.java @@ -1,149 +1,148 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.web.authentication.logout; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.web.util.UrlUtils; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; -import org.springframework.web.filter.GenericFilterBean; - -/** - * Logs a principal out. - *

    - * Polls a series of {@link LogoutHandler}s. The handlers should be specified in the order they are required. - * Generally you will want to call logout handlers TokenBasedRememberMeServices and - * SecurityContextLogoutHandler (in that order). - *

    - * After logout, a redirect will be performed to the URL determined by either the configured - * LogoutSuccessHandler or the logoutSuccessUrl, depending on which constructor was used. - * - * @author Ben Alex - * @version $Id$ - */ -public class LogoutFilter extends GenericFilterBean { - - //~ Instance fields ================================================================================================ - - private String filterProcessesUrl = "/j_spring_security_logout"; - private List handlers; - private LogoutSuccessHandler logoutSuccessHandler; - - //~ Constructors =================================================================================================== - - /** - * Constructor which takes a LogoutSuccessHandler instance to determine the target destination - * after logging out. The list of LogoutHandlers are intended to perform the actual logout functionality - * (such as clearing the security context, invalidating the session, etc.). - */ - public LogoutFilter(LogoutSuccessHandler logoutSuccessHandler, LogoutHandler... handlers) { - Assert.notEmpty(handlers, "LogoutHandlers are required"); - this.handlers = Arrays.asList(handlers); - Assert.notNull(logoutSuccessHandler, "logoutSuccessHandler cannot be null"); - this.logoutSuccessHandler = logoutSuccessHandler; - } - - public LogoutFilter(String logoutSuccessUrl, LogoutHandler... handlers) { - Assert.notEmpty(handlers, "LogoutHandlers are required"); - this.handlers = Arrays.asList(handlers); - Assert.isTrue(!StringUtils.hasLength(logoutSuccessUrl) || - UrlUtils.isValidRedirectUrl(logoutSuccessUrl), logoutSuccessUrl + " isn't a valid redirect URL"); - SimpleUrlLogoutSuccessHandler urlLogoutSuccessHandler = new SimpleUrlLogoutSuccessHandler(); - if (StringUtils.hasText(logoutSuccessUrl)) { - urlLogoutSuccessHandler.setDefaultTargetUrl(logoutSuccessUrl); - } - logoutSuccessHandler = urlLogoutSuccessHandler; - } - - //~ Methods ======================================================================================================== - - public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) - throws IOException, ServletException { - HttpServletRequest request = (HttpServletRequest) req; - HttpServletResponse response = (HttpServletResponse) res; - - if (requiresLogout(request, response)) { - Authentication auth = SecurityContextHolder.getContext().getAuthentication(); - - if (logger.isDebugEnabled()) { - logger.debug("Logging out user '" + auth + "' and transferring to logout destination"); - } - - for (LogoutHandler handler : handlers) { - handler.logout(request, response, auth); - } - - logoutSuccessHandler.onLogoutSuccess(request, response, auth); - - return; - } - - chain.doFilter(request, response); - } - - /** - * Allow subclasses to modify when a logout should take place. - * - * @param request the request - * @param response the response - * - * @return true if logout should occur, false otherwise - */ - protected boolean requiresLogout(HttpServletRequest request, HttpServletResponse response) { - String uri = request.getRequestURI(); - int pathParamIndex = uri.indexOf(';'); - - if (pathParamIndex > 0) { - // strip everything from the first semi-colon - uri = uri.substring(0, pathParamIndex); - } - - int queryParamIndex = uri.indexOf('?'); - - if (queryParamIndex > 0) { - // strip everything from the first question mark - uri = uri.substring(0, queryParamIndex); - } - - if ("".equals(request.getContextPath())) { - return uri.endsWith(filterProcessesUrl); - } - - return uri.endsWith(request.getContextPath() + filterProcessesUrl); - } - - public void setFilterProcessesUrl(String filterProcessesUrl) { - Assert.isTrue(UrlUtils.isValidRedirectUrl(filterProcessesUrl), filterProcessesUrl + " isn't a valid value for" + - " 'filterProcessesUrl'"); - this.filterProcessesUrl = filterProcessesUrl; - } - - protected String getFilterProcessesUrl() { - return filterProcessesUrl; - } -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.web.authentication.logout; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.web.util.UrlUtils; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; +import org.springframework.web.filter.GenericFilterBean; + +/** + * Logs a principal out. + *

    + * Polls a series of {@link LogoutHandler}s. The handlers should be specified in the order they are required. + * Generally you will want to call logout handlers TokenBasedRememberMeServices and + * SecurityContextLogoutHandler (in that order). + *

    + * After logout, a redirect will be performed to the URL determined by either the configured + * LogoutSuccessHandler or the logoutSuccessUrl, depending on which constructor was used. + * + * @author Ben Alex + */ +public class LogoutFilter extends GenericFilterBean { + + //~ Instance fields ================================================================================================ + + private String filterProcessesUrl = "/j_spring_security_logout"; + private List handlers; + private LogoutSuccessHandler logoutSuccessHandler; + + //~ Constructors =================================================================================================== + + /** + * Constructor which takes a LogoutSuccessHandler instance to determine the target destination + * after logging out. The list of LogoutHandlers are intended to perform the actual logout functionality + * (such as clearing the security context, invalidating the session, etc.). + */ + public LogoutFilter(LogoutSuccessHandler logoutSuccessHandler, LogoutHandler... handlers) { + Assert.notEmpty(handlers, "LogoutHandlers are required"); + this.handlers = Arrays.asList(handlers); + Assert.notNull(logoutSuccessHandler, "logoutSuccessHandler cannot be null"); + this.logoutSuccessHandler = logoutSuccessHandler; + } + + public LogoutFilter(String logoutSuccessUrl, LogoutHandler... handlers) { + Assert.notEmpty(handlers, "LogoutHandlers are required"); + this.handlers = Arrays.asList(handlers); + Assert.isTrue(!StringUtils.hasLength(logoutSuccessUrl) || + UrlUtils.isValidRedirectUrl(logoutSuccessUrl), logoutSuccessUrl + " isn't a valid redirect URL"); + SimpleUrlLogoutSuccessHandler urlLogoutSuccessHandler = new SimpleUrlLogoutSuccessHandler(); + if (StringUtils.hasText(logoutSuccessUrl)) { + urlLogoutSuccessHandler.setDefaultTargetUrl(logoutSuccessUrl); + } + logoutSuccessHandler = urlLogoutSuccessHandler; + } + + //~ Methods ======================================================================================================== + + public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) + throws IOException, ServletException { + HttpServletRequest request = (HttpServletRequest) req; + HttpServletResponse response = (HttpServletResponse) res; + + if (requiresLogout(request, response)) { + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + + if (logger.isDebugEnabled()) { + logger.debug("Logging out user '" + auth + "' and transferring to logout destination"); + } + + for (LogoutHandler handler : handlers) { + handler.logout(request, response, auth); + } + + logoutSuccessHandler.onLogoutSuccess(request, response, auth); + + return; + } + + chain.doFilter(request, response); + } + + /** + * Allow subclasses to modify when a logout should take place. + * + * @param request the request + * @param response the response + * + * @return true if logout should occur, false otherwise + */ + protected boolean requiresLogout(HttpServletRequest request, HttpServletResponse response) { + String uri = request.getRequestURI(); + int pathParamIndex = uri.indexOf(';'); + + if (pathParamIndex > 0) { + // strip everything from the first semi-colon + uri = uri.substring(0, pathParamIndex); + } + + int queryParamIndex = uri.indexOf('?'); + + if (queryParamIndex > 0) { + // strip everything from the first question mark + uri = uri.substring(0, queryParamIndex); + } + + if ("".equals(request.getContextPath())) { + return uri.endsWith(filterProcessesUrl); + } + + return uri.endsWith(request.getContextPath() + filterProcessesUrl); + } + + public void setFilterProcessesUrl(String filterProcessesUrl) { + Assert.isTrue(UrlUtils.isValidRedirectUrl(filterProcessesUrl), filterProcessesUrl + " isn't a valid value for" + + " 'filterProcessesUrl'"); + this.filterProcessesUrl = filterProcessesUrl; + } + + protected String getFilterProcessesUrl() { + return filterProcessesUrl; + } +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/logout/LogoutHandler.java b/web/src/main/java/org/springframework/security/web/authentication/logout/LogoutHandler.java index c7195b14f0..ae84d5e0dc 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/logout/LogoutHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/logout/LogoutHandler.java @@ -1,44 +1,43 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.web.authentication.logout; - -import org.springframework.security.core.Authentication; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - - -/** - * Indicates a class that is able to participate in logout handling. - * - *

    - * Called by {@link LogoutFilter}. - * - * @author Ben Alex - * @version $Id$ - */ -public interface LogoutHandler { - //~ Methods ======================================================================================================== - - /** - * Causes a logout to be completed. The method must complete successfully. - * - * @param request the HTTP request - * @param response the HTTP response - * @param authentication the current principal details - */ - void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication); -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.web.authentication.logout; + +import org.springframework.security.core.Authentication; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + + +/** + * Indicates a class that is able to participate in logout handling. + * + *

    + * Called by {@link LogoutFilter}. + * + * @author Ben Alex + */ +public interface LogoutHandler { + //~ Methods ======================================================================================================== + + /** + * Causes a logout to be completed. The method must complete successfully. + * + * @param request the HTTP request + * @param response the HTTP response + * @param authentication the current principal details + */ + void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication); +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/logout/LogoutSuccessHandler.java b/web/src/main/java/org/springframework/security/web/authentication/logout/LogoutSuccessHandler.java index f154784b2e..1e4b1cbe0b 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/logout/LogoutSuccessHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/logout/LogoutSuccessHandler.java @@ -17,7 +17,6 @@ import org.springframework.security.core.Authentication; * exceptions. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface LogoutSuccessHandler { diff --git a/web/src/main/java/org/springframework/security/web/authentication/logout/SecurityContextLogoutHandler.java b/web/src/main/java/org/springframework/security/web/authentication/logout/SecurityContextLogoutHandler.java index c60fee46cb..512a65fe40 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/logout/SecurityContextLogoutHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/logout/SecurityContextLogoutHandler.java @@ -1,74 +1,73 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.web.authentication.logout; - - -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.util.Assert; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -/** - * Performs a logout by modifying the {@link org.springframework.security.core.context.SecurityContextHolder}. - *

    - * Will also invalidate the {@link HttpSession} if {@link #isInvalidateHttpSession()} is true and the - * session is not null. - * - * @author Ben Alex - * @version $Id$ - */ -public class SecurityContextLogoutHandler implements LogoutHandler { - private boolean invalidateHttpSession = true; - - //~ Methods ======================================================================================================== - - /** - * Requires the request to be passed in. - * - * @param request from which to obtain a HTTP session (cannot be null) - * @param response not used (can be null) - * @param authentication not used (can be null) - */ - public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { - Assert.notNull(request, "HttpServletRequest required"); - if (invalidateHttpSession) { - HttpSession session = request.getSession(false); - if (session != null) { - session.invalidate(); - } - } - - SecurityContextHolder.clearContext(); - } - - public boolean isInvalidateHttpSession() { - return invalidateHttpSession; - } - - /** - * Causes the {@link HttpSession} to be invalidated when this {@link LogoutHandler} is invoked. Defaults to true. - * - * @param invalidateHttpSession true if you wish the session to be invalidated (default) or false if it should - * not be. - */ - public void setInvalidateHttpSession(boolean invalidateHttpSession) { - this.invalidateHttpSession = invalidateHttpSession; - } - -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.web.authentication.logout; + + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.util.Assert; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +/** + * Performs a logout by modifying the {@link org.springframework.security.core.context.SecurityContextHolder}. + *

    + * Will also invalidate the {@link HttpSession} if {@link #isInvalidateHttpSession()} is true and the + * session is not null. + * + * @author Ben Alex + */ +public class SecurityContextLogoutHandler implements LogoutHandler { + private boolean invalidateHttpSession = true; + + //~ Methods ======================================================================================================== + + /** + * Requires the request to be passed in. + * + * @param request from which to obtain a HTTP session (cannot be null) + * @param response not used (can be null) + * @param authentication not used (can be null) + */ + public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { + Assert.notNull(request, "HttpServletRequest required"); + if (invalidateHttpSession) { + HttpSession session = request.getSession(false); + if (session != null) { + session.invalidate(); + } + } + + SecurityContextHolder.clearContext(); + } + + public boolean isInvalidateHttpSession() { + return invalidateHttpSession; + } + + /** + * Causes the {@link HttpSession} to be invalidated when this {@link LogoutHandler} is invoked. Defaults to true. + * + * @param invalidateHttpSession true if you wish the session to be invalidated (default) or false if it should + * not be. + */ + public void setInvalidateHttpSession(boolean invalidateHttpSession) { + this.invalidateHttpSession = invalidateHttpSession; + } + +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/logout/SimpleUrlLogoutSuccessHandler.java b/web/src/main/java/org/springframework/security/web/authentication/logout/SimpleUrlLogoutSuccessHandler.java index c5fffd87d5..440410f5b2 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/logout/SimpleUrlLogoutSuccessHandler.java +++ b/web/src/main/java/org/springframework/security/web/authentication/logout/SimpleUrlLogoutSuccessHandler.java @@ -14,7 +14,6 @@ import org.springframework.security.web.authentication.AbstractAuthenticationTar * base class logic. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class SimpleUrlLogoutSuccessHandler extends AbstractAuthenticationTargetUrlRequestHandler diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/AbstractPreAuthenticatedProcessingFilter.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/AbstractPreAuthenticatedProcessingFilter.java index 41eff37d9c..96117b6dd9 100755 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/AbstractPreAuthenticatedProcessingFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/AbstractPreAuthenticatedProcessingFilter.java @@ -1,242 +1,242 @@ -package org.springframework.security.web.authentication.preauth; - -import java.io.IOException; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.ApplicationEventPublisherAware; -import org.springframework.security.authentication.AuthenticationDetailsSource; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.authentication.event.InteractiveAuthenticationSuccessEvent; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; -import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; -import org.springframework.util.Assert; -import org.springframework.web.filter.GenericFilterBean; - -/** - * Base class for processing filters that handle pre-authenticated authentication requests, where it is assumed - * that the principal has already been authenticated by an external system. - *

    - * The purpose is then only to extract the necessary information on the principal from the incoming request, rather - * than to authenticate them. External authentication systems may provide this information via request data such as - * headers or cookies which the pre-authentication system can extract. It is assumed that the external system is - * responsible for the accuracy of the data and preventing the submission of forged values. - * - * Subclasses must implement the {@code getPreAuthenticatedPrincipal()} and {@code getPreAuthenticatedCredentials()} - * methods. Subclasses of this filter are typically used in combination with a - * {@code PreAuthenticatedAuthenticationProvider}, which is used to load additional data for the user. - * This provider will reject null credentials, so the {@link #getPreAuthenticatedCredentials} method should not return - * null for a valid principal. - *

    - * If the security context already contains an {@code Authentication} object (either from a invocation of the - * filter or because of some other authentication mechanism), the filter will do nothing by default. You can force - * it to check for a change in the principal by setting the {@link #setCheckForPrincipalChanges(boolean) - * checkForPrincipalChanges} property. - *

    - * By default, the filter chain will proceed when an authentication attempt fails in order to allow other - * authentication mechanisms to process the request. To reject the credentials immediately, set the - * continueFilterChainOnUnsuccessfulAuthentication flag to false. The exception raised by the - * AuthenticationManager will the be re-thrown. Note that this will not affect cases where the principal - * returned by {@link #getPreAuthenticatedPrincipal} is null, when the chain will still proceed as normal. - * - * @author Luke Taylor - * @author Ruud Senden - * @since 2.0 - */ -public abstract class AbstractPreAuthenticatedProcessingFilter extends GenericFilterBean implements - InitializingBean, ApplicationEventPublisherAware { - - private ApplicationEventPublisher eventPublisher = null; - private AuthenticationDetailsSource authenticationDetailsSource = new WebAuthenticationDetailsSource(); - private AuthenticationManager authenticationManager = null; - private boolean continueFilterChainOnUnsuccessfulAuthentication = true; - private boolean checkForPrincipalChanges; - private boolean invalidateSessionOnPrincipalChange = true; - - /** - * Check whether all required properties have been set. - */ - @Override - public void afterPropertiesSet() { - Assert.notNull(authenticationManager, "An AuthenticationManager must be set"); - } - - /** - * Try to authenticate a pre-authenticated user with Spring Security if the user has not yet been authenticated. - */ - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { - - if (logger.isDebugEnabled()) { - logger.debug("Checking secure context token: " + SecurityContextHolder.getContext().getAuthentication()); - } - - if (requiresAuthentication((HttpServletRequest) request)) { - doAuthenticate((HttpServletRequest) request, (HttpServletResponse) response); - } - - chain.doFilter(request, response); - } - - /** - * Do the actual authentication for a pre-authenticated user. - */ - private void doAuthenticate(HttpServletRequest request, HttpServletResponse response) { - Authentication authResult = null; - - Object principal = getPreAuthenticatedPrincipal(request); - Object credentials = getPreAuthenticatedCredentials(request); - - if (principal == null) { - if (logger.isDebugEnabled()) { - logger.debug("No pre-authenticated principal found in request"); - } - - return; - } - - if (logger.isDebugEnabled()) { - logger.debug("preAuthenticatedPrincipal = " + principal + ", trying to authenticate"); - } - - try { - PreAuthenticatedAuthenticationToken authRequest = new PreAuthenticatedAuthenticationToken(principal, credentials); - authRequest.setDetails(authenticationDetailsSource.buildDetails(request)); - authResult = authenticationManager.authenticate(authRequest); - successfulAuthentication(request, response, authResult); - } catch (AuthenticationException failed) { - unsuccessfulAuthentication(request, response, failed); - - if (!continueFilterChainOnUnsuccessfulAuthentication) { - throw failed; - } - } - } - - private boolean requiresAuthentication(HttpServletRequest request) { - Authentication currentUser = SecurityContextHolder.getContext().getAuthentication(); - - if (currentUser == null) { - return true; - } - - Object principal = getPreAuthenticatedPrincipal(request); - if (checkForPrincipalChanges && - !currentUser.getName().equals(principal)) { - logger.debug("Pre-authenticated principal has changed to " + principal + " and will be reauthenticated"); - - if (invalidateSessionOnPrincipalChange) { - HttpSession session = request.getSession(false); - - if (session != null) { - logger.debug("Invalidating existing session"); - session.invalidate(); - } - } - - return true; - } - - return false; - } - - /** - * Puts the Authentication instance returned by the - * authentication manager into the secure context. - */ - protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) { - if (logger.isDebugEnabled()) { - logger.debug("Authentication success: " + authResult); - } - SecurityContextHolder.getContext().setAuthentication(authResult); - // Fire event - if (this.eventPublisher != null) { - eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(authResult, this.getClass())); - } - } - - /** - * Ensures the authentication object in the secure context is set to null - * when authentication fails. - */ - protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, AuthenticationException failed) { - SecurityContextHolder.clearContext(); - - if (logger.isDebugEnabled()) { - logger.debug("Cleared security context due to exception", failed); - } - request.getSession().setAttribute(AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY, failed); - } - - /** - * @param anApplicationEventPublisher - * The ApplicationEventPublisher to use - */ - public void setApplicationEventPublisher(ApplicationEventPublisher anApplicationEventPublisher) { - this.eventPublisher = anApplicationEventPublisher; - } - - /** - * @param authenticationDetailsSource - * The AuthenticationDetailsSource to use - */ - public void setAuthenticationDetailsSource(AuthenticationDetailsSource authenticationDetailsSource) { - Assert.notNull(authenticationDetailsSource, "AuthenticationDetailsSource required"); - this.authenticationDetailsSource = authenticationDetailsSource; - } - - /** - * @param authenticationManager - * The AuthenticationManager to use - */ - public void setAuthenticationManager(AuthenticationManager authenticationManager) { - this.authenticationManager = authenticationManager; - } - - public void setContinueFilterChainOnUnsuccessfulAuthentication(boolean shouldContinue) { - continueFilterChainOnUnsuccessfulAuthentication = shouldContinue; - } - - /** - * If set, the pre-authenticated principal will be checked on each request and compared - * against the name of the current Authentication object. If a change is detected, - * the user will be reauthenticated. - * - * @param checkForPrincipalChanges - */ - public void setCheckForPrincipalChanges(boolean checkForPrincipalChanges) { - this.checkForPrincipalChanges = checkForPrincipalChanges; - } - - /** - * If checkForPrincipalChanges is set, and a change of principal is detected, determines whether - * any existing session should be invalidated before proceeding to authenticate the new principal. - * - * @param invalidateSessionOnPrincipalChange false to retain the existing session. Defaults to true. - */ - public void setInvalidateSessionOnPrincipalChange(boolean invalidateSessionOnPrincipalChange) { - this.invalidateSessionOnPrincipalChange = invalidateSessionOnPrincipalChange; - } - - /** - * Override to extract the principal information from the current request - */ - protected abstract Object getPreAuthenticatedPrincipal(HttpServletRequest request); - - /** - * Override to extract the credentials (if applicable) from the current request. Should not return null for a valid - * principal, though some implementations may return a dummy value. - */ - protected abstract Object getPreAuthenticatedCredentials(HttpServletRequest request); -} +package org.springframework.security.web.authentication.preauth; + +import java.io.IOException; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.context.ApplicationEventPublisherAware; +import org.springframework.security.authentication.AuthenticationDetailsSource; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.event.InteractiveAuthenticationSuccessEvent; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; +import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; +import org.springframework.util.Assert; +import org.springframework.web.filter.GenericFilterBean; + +/** + * Base class for processing filters that handle pre-authenticated authentication requests, where it is assumed + * that the principal has already been authenticated by an external system. + *

    + * The purpose is then only to extract the necessary information on the principal from the incoming request, rather + * than to authenticate them. External authentication systems may provide this information via request data such as + * headers or cookies which the pre-authentication system can extract. It is assumed that the external system is + * responsible for the accuracy of the data and preventing the submission of forged values. + * + * Subclasses must implement the {@code getPreAuthenticatedPrincipal()} and {@code getPreAuthenticatedCredentials()} + * methods. Subclasses of this filter are typically used in combination with a + * {@code PreAuthenticatedAuthenticationProvider}, which is used to load additional data for the user. + * This provider will reject null credentials, so the {@link #getPreAuthenticatedCredentials} method should not return + * null for a valid principal. + *

    + * If the security context already contains an {@code Authentication} object (either from a invocation of the + * filter or because of some other authentication mechanism), the filter will do nothing by default. You can force + * it to check for a change in the principal by setting the {@link #setCheckForPrincipalChanges(boolean) + * checkForPrincipalChanges} property. + *

    + * By default, the filter chain will proceed when an authentication attempt fails in order to allow other + * authentication mechanisms to process the request. To reject the credentials immediately, set the + * continueFilterChainOnUnsuccessfulAuthentication flag to false. The exception raised by the + * AuthenticationManager will the be re-thrown. Note that this will not affect cases where the principal + * returned by {@link #getPreAuthenticatedPrincipal} is null, when the chain will still proceed as normal. + * + * @author Luke Taylor + * @author Ruud Senden + * @since 2.0 + */ +public abstract class AbstractPreAuthenticatedProcessingFilter extends GenericFilterBean implements + InitializingBean, ApplicationEventPublisherAware { + + private ApplicationEventPublisher eventPublisher = null; + private AuthenticationDetailsSource authenticationDetailsSource = new WebAuthenticationDetailsSource(); + private AuthenticationManager authenticationManager = null; + private boolean continueFilterChainOnUnsuccessfulAuthentication = true; + private boolean checkForPrincipalChanges; + private boolean invalidateSessionOnPrincipalChange = true; + + /** + * Check whether all required properties have been set. + */ + @Override + public void afterPropertiesSet() { + Assert.notNull(authenticationManager, "An AuthenticationManager must be set"); + } + + /** + * Try to authenticate a pre-authenticated user with Spring Security if the user has not yet been authenticated. + */ + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + + if (logger.isDebugEnabled()) { + logger.debug("Checking secure context token: " + SecurityContextHolder.getContext().getAuthentication()); + } + + if (requiresAuthentication((HttpServletRequest) request)) { + doAuthenticate((HttpServletRequest) request, (HttpServletResponse) response); + } + + chain.doFilter(request, response); + } + + /** + * Do the actual authentication for a pre-authenticated user. + */ + private void doAuthenticate(HttpServletRequest request, HttpServletResponse response) { + Authentication authResult = null; + + Object principal = getPreAuthenticatedPrincipal(request); + Object credentials = getPreAuthenticatedCredentials(request); + + if (principal == null) { + if (logger.isDebugEnabled()) { + logger.debug("No pre-authenticated principal found in request"); + } + + return; + } + + if (logger.isDebugEnabled()) { + logger.debug("preAuthenticatedPrincipal = " + principal + ", trying to authenticate"); + } + + try { + PreAuthenticatedAuthenticationToken authRequest = new PreAuthenticatedAuthenticationToken(principal, credentials); + authRequest.setDetails(authenticationDetailsSource.buildDetails(request)); + authResult = authenticationManager.authenticate(authRequest); + successfulAuthentication(request, response, authResult); + } catch (AuthenticationException failed) { + unsuccessfulAuthentication(request, response, failed); + + if (!continueFilterChainOnUnsuccessfulAuthentication) { + throw failed; + } + } + } + + private boolean requiresAuthentication(HttpServletRequest request) { + Authentication currentUser = SecurityContextHolder.getContext().getAuthentication(); + + if (currentUser == null) { + return true; + } + + Object principal = getPreAuthenticatedPrincipal(request); + if (checkForPrincipalChanges && + !currentUser.getName().equals(principal)) { + logger.debug("Pre-authenticated principal has changed to " + principal + " and will be reauthenticated"); + + if (invalidateSessionOnPrincipalChange) { + HttpSession session = request.getSession(false); + + if (session != null) { + logger.debug("Invalidating existing session"); + session.invalidate(); + } + } + + return true; + } + + return false; + } + + /** + * Puts the Authentication instance returned by the + * authentication manager into the secure context. + */ + protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) { + if (logger.isDebugEnabled()) { + logger.debug("Authentication success: " + authResult); + } + SecurityContextHolder.getContext().setAuthentication(authResult); + // Fire event + if (this.eventPublisher != null) { + eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(authResult, this.getClass())); + } + } + + /** + * Ensures the authentication object in the secure context is set to null + * when authentication fails. + */ + protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, AuthenticationException failed) { + SecurityContextHolder.clearContext(); + + if (logger.isDebugEnabled()) { + logger.debug("Cleared security context due to exception", failed); + } + request.getSession().setAttribute(AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY, failed); + } + + /** + * @param anApplicationEventPublisher + * The ApplicationEventPublisher to use + */ + public void setApplicationEventPublisher(ApplicationEventPublisher anApplicationEventPublisher) { + this.eventPublisher = anApplicationEventPublisher; + } + + /** + * @param authenticationDetailsSource + * The AuthenticationDetailsSource to use + */ + public void setAuthenticationDetailsSource(AuthenticationDetailsSource authenticationDetailsSource) { + Assert.notNull(authenticationDetailsSource, "AuthenticationDetailsSource required"); + this.authenticationDetailsSource = authenticationDetailsSource; + } + + /** + * @param authenticationManager + * The AuthenticationManager to use + */ + public void setAuthenticationManager(AuthenticationManager authenticationManager) { + this.authenticationManager = authenticationManager; + } + + public void setContinueFilterChainOnUnsuccessfulAuthentication(boolean shouldContinue) { + continueFilterChainOnUnsuccessfulAuthentication = shouldContinue; + } + + /** + * If set, the pre-authenticated principal will be checked on each request and compared + * against the name of the current Authentication object. If a change is detected, + * the user will be reauthenticated. + * + * @param checkForPrincipalChanges + */ + public void setCheckForPrincipalChanges(boolean checkForPrincipalChanges) { + this.checkForPrincipalChanges = checkForPrincipalChanges; + } + + /** + * If checkForPrincipalChanges is set, and a change of principal is detected, determines whether + * any existing session should be invalidated before proceeding to authenticate the new principal. + * + * @param invalidateSessionOnPrincipalChange false to retain the existing session. Defaults to true. + */ + public void setInvalidateSessionOnPrincipalChange(boolean invalidateSessionOnPrincipalChange) { + this.invalidateSessionOnPrincipalChange = invalidateSessionOnPrincipalChange; + } + + /** + * Override to extract the principal information from the current request + */ + protected abstract Object getPreAuthenticatedPrincipal(HttpServletRequest request); + + /** + * Override to extract the credentials (if applicable) from the current request. Should not return null for a valid + * principal, though some implementations may return a dummy value. + */ + protected abstract Object getPreAuthenticatedCredentials(HttpServletRequest request); +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProvider.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProvider.java index 2c3fd56836..46a1096595 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProvider.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProvider.java @@ -1,134 +1,133 @@ -package org.springframework.security.web.authentication.preauth; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.core.Ordered; -import org.springframework.security.authentication.AccountStatusUserDetailsChecker; -import org.springframework.security.authentication.AuthenticationProvider; -import org.springframework.security.authentication.BadCredentialsException; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsChecker; -import org.springframework.util.Assert; - -/** - *

    - * Processes a pre-authenticated authentication request. The request will - * typically originate from a {@link org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter} - * subclass. - * - *

    - * This authentication provider will not perform any checks on authentication - * requests, as they should already be pre-authenticated. However, the - * AuthenticationUserDetailsService implementation may still throw a UsernameNotFoundException, for example. - * - * @author Ruud Senden - * @version $Id$ - * @since 2.0 - */ -public class PreAuthenticatedAuthenticationProvider implements AuthenticationProvider, InitializingBean, Ordered { - private static final Log logger = LogFactory.getLog(PreAuthenticatedAuthenticationProvider.class); - - private AuthenticationUserDetailsService preAuthenticatedUserDetailsService = null; - private UserDetailsChecker userDetailsChecker = new AccountStatusUserDetailsChecker(); - private boolean throwExceptionWhenTokenRejected = false; - - private int order = -1; // default: same as non-ordered - - /** - * Check whether all required properties have been set. - */ - public void afterPropertiesSet() { - Assert.notNull(preAuthenticatedUserDetailsService, "An AuthenticationUserDetailsService must be set"); - } - - /** - * Authenticate the given PreAuthenticatedAuthenticationToken. - *

    - * If the principal contained in the authentication object is null, the request will be ignored to allow other - * providers to authenticate it. - */ - public Authentication authenticate(Authentication authentication) throws AuthenticationException { - if (!supports(authentication.getClass())) { - return null; - } - - if (logger.isDebugEnabled()) { - logger.debug("PreAuthenticated authentication request: " + authentication); - } - - if (authentication.getPrincipal() == null) { - logger.debug("No pre-authenticated principal found in request."); - - if (throwExceptionWhenTokenRejected) { - throw new BadCredentialsException("No pre-authenticated principal found in request."); - } - return null; - } - - if (authentication.getCredentials() == null) { - logger.debug("No pre-authenticated credentials found in request."); - - if (throwExceptionWhenTokenRejected) { - throw new BadCredentialsException("No pre-authenticated credentials found in request."); - } - return null; - } - - UserDetails ud = preAuthenticatedUserDetailsService.loadUserDetails(authentication); - - userDetailsChecker.check(ud); - - PreAuthenticatedAuthenticationToken result = - new PreAuthenticatedAuthenticationToken(ud, authentication.getCredentials(), ud.getAuthorities()); - result.setDetails(authentication.getDetails()); - - return result; - } - - /** - * Indicate that this provider only supports PreAuthenticatedAuthenticationToken (sub)classes. - */ - public boolean supports(Class authentication) { - return PreAuthenticatedAuthenticationToken.class.isAssignableFrom(authentication); - } - - /** - * Set the AuthenticatedUserDetailsServices to be used. - * - * @param aPreAuthenticatedUserDetailsService - */ - public void setPreAuthenticatedUserDetailsService(AuthenticationUserDetailsService aPreAuthenticatedUserDetailsService) { - this.preAuthenticatedUserDetailsService = aPreAuthenticatedUserDetailsService; - } - - public int getOrder() { - return order; - } - - public void setOrder(int i) { - order = i; - } - - /** - * If true, causes the provider to throw a BadCredentialsException if the presented authentication - * request is invalid (contains a null principal or credentials). Otherwise it will just return - * null. Defaults to false. - */ - public void setThrowExceptionWhenTokenRejected(boolean throwExceptionWhenTokenRejected) { - this.throwExceptionWhenTokenRejected = throwExceptionWhenTokenRejected; - } - - /** - * Sets the strategy which will be used to validate the loaded UserDetails object - * for the user. Defaults to an {@link AccountStatusUserDetailsChecker}. - * @param userDetailsChecker - */ - public void setUserDetailsChecker(UserDetailsChecker userDetailsChecker) { - Assert.notNull(userDetailsChecker, "userDetailsChacker cannot be null"); - this.userDetailsChecker = userDetailsChecker; - } -} +package org.springframework.security.web.authentication.preauth; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.Ordered; +import org.springframework.security.authentication.AccountStatusUserDetailsChecker; +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsChecker; +import org.springframework.util.Assert; + +/** + *

    + * Processes a pre-authenticated authentication request. The request will + * typically originate from a {@link org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter} + * subclass. + * + *

    + * This authentication provider will not perform any checks on authentication + * requests, as they should already be pre-authenticated. However, the + * AuthenticationUserDetailsService implementation may still throw a UsernameNotFoundException, for example. + * + * @author Ruud Senden + * @since 2.0 + */ +public class PreAuthenticatedAuthenticationProvider implements AuthenticationProvider, InitializingBean, Ordered { + private static final Log logger = LogFactory.getLog(PreAuthenticatedAuthenticationProvider.class); + + private AuthenticationUserDetailsService preAuthenticatedUserDetailsService = null; + private UserDetailsChecker userDetailsChecker = new AccountStatusUserDetailsChecker(); + private boolean throwExceptionWhenTokenRejected = false; + + private int order = -1; // default: same as non-ordered + + /** + * Check whether all required properties have been set. + */ + public void afterPropertiesSet() { + Assert.notNull(preAuthenticatedUserDetailsService, "An AuthenticationUserDetailsService must be set"); + } + + /** + * Authenticate the given PreAuthenticatedAuthenticationToken. + *

    + * If the principal contained in the authentication object is null, the request will be ignored to allow other + * providers to authenticate it. + */ + public Authentication authenticate(Authentication authentication) throws AuthenticationException { + if (!supports(authentication.getClass())) { + return null; + } + + if (logger.isDebugEnabled()) { + logger.debug("PreAuthenticated authentication request: " + authentication); + } + + if (authentication.getPrincipal() == null) { + logger.debug("No pre-authenticated principal found in request."); + + if (throwExceptionWhenTokenRejected) { + throw new BadCredentialsException("No pre-authenticated principal found in request."); + } + return null; + } + + if (authentication.getCredentials() == null) { + logger.debug("No pre-authenticated credentials found in request."); + + if (throwExceptionWhenTokenRejected) { + throw new BadCredentialsException("No pre-authenticated credentials found in request."); + } + return null; + } + + UserDetails ud = preAuthenticatedUserDetailsService.loadUserDetails(authentication); + + userDetailsChecker.check(ud); + + PreAuthenticatedAuthenticationToken result = + new PreAuthenticatedAuthenticationToken(ud, authentication.getCredentials(), ud.getAuthorities()); + result.setDetails(authentication.getDetails()); + + return result; + } + + /** + * Indicate that this provider only supports PreAuthenticatedAuthenticationToken (sub)classes. + */ + public boolean supports(Class authentication) { + return PreAuthenticatedAuthenticationToken.class.isAssignableFrom(authentication); + } + + /** + * Set the AuthenticatedUserDetailsServices to be used. + * + * @param aPreAuthenticatedUserDetailsService + */ + public void setPreAuthenticatedUserDetailsService(AuthenticationUserDetailsService aPreAuthenticatedUserDetailsService) { + this.preAuthenticatedUserDetailsService = aPreAuthenticatedUserDetailsService; + } + + public int getOrder() { + return order; + } + + public void setOrder(int i) { + order = i; + } + + /** + * If true, causes the provider to throw a BadCredentialsException if the presented authentication + * request is invalid (contains a null principal or credentials). Otherwise it will just return + * null. Defaults to false. + */ + public void setThrowExceptionWhenTokenRejected(boolean throwExceptionWhenTokenRejected) { + this.throwExceptionWhenTokenRejected = throwExceptionWhenTokenRejected; + } + + /** + * Sets the strategy which will be used to validate the loaded UserDetails object + * for the user. Defaults to an {@link AccountStatusUserDetailsChecker}. + * @param userDetailsChecker + */ + public void setUserDetailsChecker(UserDetailsChecker userDetailsChecker) { + Assert.notNull(userDetailsChecker, "userDetailsChacker cannot be null"); + this.userDetailsChecker = userDetailsChecker; + } +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationToken.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationToken.java index f9dfe6ad59..5248bd9fb2 100755 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationToken.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationToken.java @@ -1,73 +1,73 @@ -package org.springframework.security.web.authentication.preauth; - -import java.util.Collection; - -import org.springframework.security.authentication.AbstractAuthenticationToken; -import org.springframework.security.core.GrantedAuthority; - - -/** - * {@link org.springframework.security.core.Authentication} implementation for pre-authenticated - * authentication. - * - * @author Ruud Senden - * @since 2.0 - */ -public class PreAuthenticatedAuthenticationToken extends AbstractAuthenticationToken { - private final Object principal; - private final Object credentials; - - /** - * Constructor used for an authentication request. The {@link - * org.springframework.security.core.Authentication#isAuthenticated()} will return - * false. - * - * @TODO Should we have only a single credentials parameter here? For - * example for X509 the certificate is used as credentials, while - * currently a J2EE username is specified as a principal but could as - * well be set as credentials. - * - * @param aPrincipal - * The pre-authenticated principal - * @param aCredentials - * The pre-authenticated credentials - */ - public PreAuthenticatedAuthenticationToken(Object aPrincipal, Object aCredentials) { - super(null); - this.principal = aPrincipal; - this.credentials = aCredentials; - } - - - /** - * Constructor used for an authentication response. The {@link - * org.springframework.security.core.Authentication#isAuthenticated()} will return - * true. - * - * @param aPrincipal - * The authenticated principal - * @param anAuthorities - * The granted authorities - */ - public PreAuthenticatedAuthenticationToken(Object aPrincipal, Object aCredentials, Collection anAuthorities) { - super(anAuthorities); - this.principal = aPrincipal; - this.credentials = aCredentials; - setAuthenticated(true); - } - - /** - * Get the credentials - */ - public Object getCredentials() { - return this.credentials; - } - - /** - * Get the principal - */ - public Object getPrincipal() { - return this.principal; - } - -} +package org.springframework.security.web.authentication.preauth; + +import java.util.Collection; + +import org.springframework.security.authentication.AbstractAuthenticationToken; +import org.springframework.security.core.GrantedAuthority; + + +/** + * {@link org.springframework.security.core.Authentication} implementation for pre-authenticated + * authentication. + * + * @author Ruud Senden + * @since 2.0 + */ +public class PreAuthenticatedAuthenticationToken extends AbstractAuthenticationToken { + private final Object principal; + private final Object credentials; + + /** + * Constructor used for an authentication request. The {@link + * org.springframework.security.core.Authentication#isAuthenticated()} will return + * false. + * + * @TODO Should we have only a single credentials parameter here? For + * example for X509 the certificate is used as credentials, while + * currently a J2EE username is specified as a principal but could as + * well be set as credentials. + * + * @param aPrincipal + * The pre-authenticated principal + * @param aCredentials + * The pre-authenticated credentials + */ + public PreAuthenticatedAuthenticationToken(Object aPrincipal, Object aCredentials) { + super(null); + this.principal = aPrincipal; + this.credentials = aCredentials; + } + + + /** + * Constructor used for an authentication response. The {@link + * org.springframework.security.core.Authentication#isAuthenticated()} will return + * true. + * + * @param aPrincipal + * The authenticated principal + * @param anAuthorities + * The granted authorities + */ + public PreAuthenticatedAuthenticationToken(Object aPrincipal, Object aCredentials, Collection anAuthorities) { + super(anAuthorities); + this.principal = aPrincipal; + this.credentials = aCredentials; + setAuthenticated(true); + } + + /** + * Get the credentials + */ + public Object getCredentials() { + return this.credentials; + } + + /** + * Get the principal + */ + public Object getPrincipal() { + return this.principal; + } + +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesUserDetailsService.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesUserDetailsService.java index 8d0b1e3ad1..b4e66adf5d 100755 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesUserDetailsService.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesUserDetailsService.java @@ -1,57 +1,57 @@ -package org.springframework.security.web.authentication.preauth; - -import java.util.List; - -import org.springframework.security.core.Authentication; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthoritiesContainer; -import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; - -import org.springframework.util.Assert; - -/** - *

    - * This AuthenticationUserDetailsService implementation creates a UserDetails - * object based solely on the information contained in the given - * PreAuthenticatedAuthenticationToken. The user name is set to the name as - * returned by PreAuthenticatedAuthenticationToken.getName(), the password is - * set to a fixed dummy value (it will not be used by the - * PreAuthenticatedAuthenticationProvider anyway), and the Granted Authorities - * are retrieved from the details object as returned by - * PreAuthenticatedAuthenticationToken.getDetails(). - * - *

    - * The details object as returned by PreAuthenticatedAuthenticationToken.getDetails() must implement the - * {@link GrantedAuthoritiesContainer} interface for this implementation to work. - * - * @author Ruud Senden - * @since 2.0 - */ -public class PreAuthenticatedGrantedAuthoritiesUserDetailsService implements AuthenticationUserDetailsService { - /** - * Get a UserDetails object based on the user name contained in the given - * token, and the GrantedAuthorities as returned by the - * GrantedAuthoritiesContainer implementation as returned by - * the token.getDetails() method. - */ - public final UserDetails loadUserDetails(Authentication token) throws AuthenticationException { - Assert.notNull(token.getDetails()); - Assert.isInstanceOf(GrantedAuthoritiesContainer.class, token.getDetails()); - List authorities = ((GrantedAuthoritiesContainer) token.getDetails()).getGrantedAuthorities(); - UserDetails ud = createuserDetails(token, authorities); - return ud; - } - - /** - * Creates the final UserDetails object. Can be overridden to customize the contents. - * - * @param token the authentication request token - * @param authorities the pre-authenticated authorities. - */ - protected UserDetails createuserDetails(Authentication token, List authorities) { - return new User(token.getName(), "N/A", true, true, true, true, authorities); - } -} +package org.springframework.security.web.authentication.preauth; + +import java.util.List; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.GrantedAuthoritiesContainer; +import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; + +import org.springframework.util.Assert; + +/** + *

    + * This AuthenticationUserDetailsService implementation creates a UserDetails + * object based solely on the information contained in the given + * PreAuthenticatedAuthenticationToken. The user name is set to the name as + * returned by PreAuthenticatedAuthenticationToken.getName(), the password is + * set to a fixed dummy value (it will not be used by the + * PreAuthenticatedAuthenticationProvider anyway), and the Granted Authorities + * are retrieved from the details object as returned by + * PreAuthenticatedAuthenticationToken.getDetails(). + * + *

    + * The details object as returned by PreAuthenticatedAuthenticationToken.getDetails() must implement the + * {@link GrantedAuthoritiesContainer} interface for this implementation to work. + * + * @author Ruud Senden + * @since 2.0 + */ +public class PreAuthenticatedGrantedAuthoritiesUserDetailsService implements AuthenticationUserDetailsService { + /** + * Get a UserDetails object based on the user name contained in the given + * token, and the GrantedAuthorities as returned by the + * GrantedAuthoritiesContainer implementation as returned by + * the token.getDetails() method. + */ + public final UserDetails loadUserDetails(Authentication token) throws AuthenticationException { + Assert.notNull(token.getDetails()); + Assert.isInstanceOf(GrantedAuthoritiesContainer.class, token.getDetails()); + List authorities = ((GrantedAuthoritiesContainer) token.getDetails()).getGrantedAuthorities(); + UserDetails ud = createuserDetails(token, authorities); + return ud; + } + + /** + * Creates the final UserDetails object. Can be overridden to customize the contents. + * + * @param token the authentication request token + * @param authorities the pre-authenticated authorities. + */ + protected UserDetails createuserDetails(Authentication token, List authorities) { + return new User(token.getName(), "N/A", true, true, true, true, authorities); + } +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails.java index c061867b77..818eb99305 100755 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails.java @@ -1,44 +1,44 @@ -package org.springframework.security.web.authentication.preauth; - -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthoritiesContainerImpl; -import org.springframework.security.core.authority.MutableGrantedAuthoritiesContainer; -import org.springframework.security.web.authentication.WebAuthenticationDetails; - -/** - * This WebAuthenticationDetails implementation allows for storing a list of - * pre-authenticated Granted Authorities. - * - * @author Ruud Senden - * @author Luke Taylor - * @since 2.0 - */ -public class PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails extends WebAuthenticationDetails implements - MutableGrantedAuthoritiesContainer { - public static final long serialVersionUID = 1L; - - private MutableGrantedAuthoritiesContainer authoritiesContainer = new GrantedAuthoritiesContainerImpl(); - - public PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails(HttpServletRequest request) { - super(request); - } - - public List getGrantedAuthorities() { - return authoritiesContainer.getGrantedAuthorities(); - } - - public void setGrantedAuthorities(List authorities) { - this.authoritiesContainer.setGrantedAuthorities(authorities); - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(super.toString() + "; "); - sb.append(authoritiesContainer); - return sb.toString(); - } -} +package org.springframework.security.web.authentication.preauth; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.GrantedAuthoritiesContainerImpl; +import org.springframework.security.core.authority.MutableGrantedAuthoritiesContainer; +import org.springframework.security.web.authentication.WebAuthenticationDetails; + +/** + * This WebAuthenticationDetails implementation allows for storing a list of + * pre-authenticated Granted Authorities. + * + * @author Ruud Senden + * @author Luke Taylor + * @since 2.0 + */ +public class PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails extends WebAuthenticationDetails implements + MutableGrantedAuthoritiesContainer { + public static final long serialVersionUID = 1L; + + private MutableGrantedAuthoritiesContainer authoritiesContainer = new GrantedAuthoritiesContainerImpl(); + + public PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails(HttpServletRequest request) { + super(request); + } + + public List getGrantedAuthorities() { + return authoritiesContainer.getGrantedAuthorities(); + } + + public void setGrantedAuthorities(List authorities) { + this.authoritiesContainer.setGrantedAuthorities(authorities); + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(super.toString() + "; "); + sb.append(authoritiesContainer); + return sb.toString(); + } +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedProcessingFilterEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedProcessingFilterEntryPoint.java index d64a1e5561..7ff50147cb 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedProcessingFilterEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedProcessingFilterEntryPoint.java @@ -8,7 +8,6 @@ import org.springframework.security.web.authentication.Http403ForbiddenEntryPoin * See {@link Http403ForbiddenEntryPoint}. * * @author Luke Taylor - * @version $Id$ * @deprecated Use Http403ForbiddenEntryPoint instead. */ public class PreAuthenticatedProcessingFilterEntryPoint extends Http403ForbiddenEntryPoint { diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/RequestHeaderAuthenticationFilter.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/RequestHeaderAuthenticationFilter.java index 323354ab0f..ec656c3f02 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/RequestHeaderAuthenticationFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/RequestHeaderAuthenticationFilter.java @@ -23,7 +23,6 @@ import org.springframework.util.Assert; * * * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public class RequestHeaderAuthenticationFilter extends AbstractPreAuthenticatedProcessingFilter { diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource.java index 10081d8e1b..54709faa38 100755 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource.java @@ -1,49 +1,49 @@ -package org.springframework.security.web.authentication.preauth.j2ee; - -import org.springframework.security.web.authentication.preauth.PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails; -import org.springframework.security.core.authority.mapping.SimpleAttributes2GrantedAuthoritiesMapper; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; - -/** - * Implementation of AuthenticationDetailsSource which converts the user's J2EE roles (as obtained by calling - * {@link HttpServletRequest#isUserInRole(String)}) into GrantedAuthoritys and stores these in the authentication - * details object (. - * - * @author Ruud Senden - * @since 2.0 - */ -public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource extends AbstractPreAuthenticatedAuthenticationDetailsSource { - /** - * Public constructor which overrides the default AuthenticationDetails - * class to be used. - */ - public J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource() { - super.setClazz(PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails.class); - - j2eeUserRoles2GrantedAuthoritiesMapper = new SimpleAttributes2GrantedAuthoritiesMapper(); - } - - /** - * Obtains the list of user roles based on the current user's J2EE roles. - * - * @param request The request against which isUserInRole will be called for each role name - * returned by the MappableAttributesRetriever. - * @return GrantedAuthority[] mapped from the user's J2EE roles. - */ - protected Collection getUserRoles(Object context, Set mappableRoles) { - ArrayList j2eeUserRolesList = new ArrayList(); - - for (String role : mappableRoles) { - if (((HttpServletRequest)context).isUserInRole(role)) { - j2eeUserRolesList.add(role); - } - } - - return j2eeUserRolesList; - } -} +package org.springframework.security.web.authentication.preauth.j2ee; + +import org.springframework.security.web.authentication.preauth.PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails; +import org.springframework.security.core.authority.mapping.SimpleAttributes2GrantedAuthoritiesMapper; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; + +/** + * Implementation of AuthenticationDetailsSource which converts the user's J2EE roles (as obtained by calling + * {@link HttpServletRequest#isUserInRole(String)}) into GrantedAuthoritys and stores these in the authentication + * details object (. + * + * @author Ruud Senden + * @since 2.0 + */ +public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource extends AbstractPreAuthenticatedAuthenticationDetailsSource { + /** + * Public constructor which overrides the default AuthenticationDetails + * class to be used. + */ + public J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource() { + super.setClazz(PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails.class); + + j2eeUserRoles2GrantedAuthoritiesMapper = new SimpleAttributes2GrantedAuthoritiesMapper(); + } + + /** + * Obtains the list of user roles based on the current user's J2EE roles. + * + * @param request The request against which isUserInRole will be called for each role name + * returned by the MappableAttributesRetriever. + * @return GrantedAuthority[] mapped from the user's J2EE roles. + */ + protected Collection getUserRoles(Object context, Set mappableRoles) { + ArrayList j2eeUserRolesList = new ArrayList(); + + for (String role : mappableRoles) { + if (((HttpServletRequest)context).isUserInRole(role)) { + j2eeUserRolesList.add(role); + } + } + + return j2eeUserRolesList; + } +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/J2eePreAuthenticatedProcessingFilter.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/J2eePreAuthenticatedProcessingFilter.java index f2fb014b5a..a99ea59842 100755 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/J2eePreAuthenticatedProcessingFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/J2eePreAuthenticatedProcessingFilter.java @@ -1,36 +1,36 @@ -package org.springframework.security.web.authentication.preauth.j2ee; - -import javax.servlet.http.HttpServletRequest; - -import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter; - -/** - * This AbstractPreAuthenticatedProcessingFilter implementation is based on the - * J2EE container-based authentication mechanism. It will use the J2EE user - * principal name as the pre-authenticated principal. - * - * @author Ruud Senden - * @since 2.0 - */ -public class J2eePreAuthenticatedProcessingFilter extends AbstractPreAuthenticatedProcessingFilter { - - /** - * Return the J2EE user name. - */ - protected Object getPreAuthenticatedPrincipal(HttpServletRequest httpRequest) { - Object principal = httpRequest.getUserPrincipal() == null ? null : httpRequest.getUserPrincipal().getName(); - if (logger.isDebugEnabled()) { - logger.debug("PreAuthenticated J2EE principal: " + principal); - } - return principal; - } - - /** - * For J2EE container-based authentication there is no generic way to - * retrieve the credentials, as such this method returns a fixed dummy - * value. - */ - protected Object getPreAuthenticatedCredentials(HttpServletRequest httpRequest) { - return "N/A"; - } -} +package org.springframework.security.web.authentication.preauth.j2ee; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter; + +/** + * This AbstractPreAuthenticatedProcessingFilter implementation is based on the + * J2EE container-based authentication mechanism. It will use the J2EE user + * principal name as the pre-authenticated principal. + * + * @author Ruud Senden + * @since 2.0 + */ +public class J2eePreAuthenticatedProcessingFilter extends AbstractPreAuthenticatedProcessingFilter { + + /** + * Return the J2EE user name. + */ + protected Object getPreAuthenticatedPrincipal(HttpServletRequest httpRequest) { + Object principal = httpRequest.getUserPrincipal() == null ? null : httpRequest.getUserPrincipal().getName(); + if (logger.isDebugEnabled()) { + logger.debug("PreAuthenticated J2EE principal: " + principal); + } + return principal; + } + + /** + * For J2EE container-based authentication there is no generic way to + * retrieve the credentials, as such this method returns a fixed dummy + * value. + */ + protected Object getPreAuthenticatedCredentials(HttpServletRequest httpRequest) { + return "N/A"; + } +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/WebXmlMappableAttributesRetriever.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/WebXmlMappableAttributesRetriever.java index b065246316..2aa1edf2ad 100755 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/WebXmlMappableAttributesRetriever.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/j2ee/WebXmlMappableAttributesRetriever.java @@ -1,123 +1,123 @@ -package org.springframework.security.web.authentication.preauth.j2ee; - -import java.io.IOException; -import java.io.InputStream; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.FactoryConfigurationError; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.context.ResourceLoaderAware; -import org.springframework.core.io.Resource; -import org.springframework.core.io.ResourceLoader; -import org.springframework.security.core.authority.mapping.MappableAttributesRetriever; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -/** - * This MappableAttributesRetriever implementation reads the list of defined J2EE - * roles from a web.xml file and returns these from {{@link #getMappableAttributes()}. - * - * @author Ruud Senden - * @author Luke Taylor - * @since 2.0 - */ -public class WebXmlMappableAttributesRetriever implements ResourceLoaderAware, MappableAttributesRetriever, InitializingBean { - protected final Log logger = LogFactory.getLog(getClass()); - - private ResourceLoader resourceLoader; - private Set mappableAttributes; - - public void setResourceLoader(ResourceLoader resourceLoader) { - this.resourceLoader = resourceLoader; - } - - - public Set getMappableAttributes() { - return mappableAttributes; - } - - /** - * Loads the web.xml file using the configured ResourceLoader and - * parses the role-name elements from it, using these as the set of mappableAttributes. - */ - - public void afterPropertiesSet() throws Exception { - Resource webXml = resourceLoader.getResource("/WEB-INF/web.xml"); - Document doc = getDocument(webXml.getInputStream()); - NodeList webApp = doc.getElementsByTagName("web-app"); - if (webApp.getLength() != 1) { - throw new IllegalArgumentException("Failed to find 'web-app' element in resource" + webXml); - } - NodeList securityRoles = ((Element)webApp.item(0)).getElementsByTagName("security-role"); - - ArrayList roleNames = new ArrayList(); - - for (int i=0; i < securityRoles.getLength(); i++) { - Element secRoleElt = (Element) securityRoles.item(i); - NodeList roles = secRoleElt.getElementsByTagName("role-name"); - - if (roles.getLength() > 0) { - String roleName = ((Element)roles.item(0)).getTextContent().trim(); - roleNames.add(roleName); - logger.info("Retrieved role-name '" + roleName + "' from web.xml"); - } else { - logger.info("No security-role elements found in " + webXml); - } - } - - mappableAttributes = Collections.unmodifiableSet(new HashSet(roleNames)); - } - - /** - * @return Document for the specified InputStream - */ - private Document getDocument(InputStream aStream) { - Document doc; - try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setValidating(false); - DocumentBuilder db = factory.newDocumentBuilder(); - db.setEntityResolver(new MyEntityResolver()); - doc = db.parse(aStream); - return doc; - } catch (FactoryConfigurationError e) { - throw new RuntimeException("Unable to parse document object", e); - } catch (ParserConfigurationException e) { - throw new RuntimeException("Unable to parse document object", e); - } catch (SAXException e) { - throw new RuntimeException("Unable to parse document object", e); - } catch (IOException e) { - throw new RuntimeException("Unable to parse document object", e); - } finally { - try { - aStream.close(); - } catch (IOException e) { - logger.warn("Failed to close input stream for web.xml", e); - } - } - } - - /** - * We do not need to resolve external entities, so just return an empty - * String. - */ - private static final class MyEntityResolver implements EntityResolver { - public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { - return new InputSource(new StringReader("")); - } - } -} +package org.springframework.security.web.authentication.preauth.j2ee; + +import java.io.IOException; +import java.io.InputStream; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.FactoryConfigurationError; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.context.ResourceLoaderAware; +import org.springframework.core.io.Resource; +import org.springframework.core.io.ResourceLoader; +import org.springframework.security.core.authority.mapping.MappableAttributesRetriever; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/** + * This MappableAttributesRetriever implementation reads the list of defined J2EE + * roles from a web.xml file and returns these from {{@link #getMappableAttributes()}. + * + * @author Ruud Senden + * @author Luke Taylor + * @since 2.0 + */ +public class WebXmlMappableAttributesRetriever implements ResourceLoaderAware, MappableAttributesRetriever, InitializingBean { + protected final Log logger = LogFactory.getLog(getClass()); + + private ResourceLoader resourceLoader; + private Set mappableAttributes; + + public void setResourceLoader(ResourceLoader resourceLoader) { + this.resourceLoader = resourceLoader; + } + + + public Set getMappableAttributes() { + return mappableAttributes; + } + + /** + * Loads the web.xml file using the configured ResourceLoader and + * parses the role-name elements from it, using these as the set of mappableAttributes. + */ + + public void afterPropertiesSet() throws Exception { + Resource webXml = resourceLoader.getResource("/WEB-INF/web.xml"); + Document doc = getDocument(webXml.getInputStream()); + NodeList webApp = doc.getElementsByTagName("web-app"); + if (webApp.getLength() != 1) { + throw new IllegalArgumentException("Failed to find 'web-app' element in resource" + webXml); + } + NodeList securityRoles = ((Element)webApp.item(0)).getElementsByTagName("security-role"); + + ArrayList roleNames = new ArrayList(); + + for (int i=0; i < securityRoles.getLength(); i++) { + Element secRoleElt = (Element) securityRoles.item(i); + NodeList roles = secRoleElt.getElementsByTagName("role-name"); + + if (roles.getLength() > 0) { + String roleName = ((Element)roles.item(0)).getTextContent().trim(); + roleNames.add(roleName); + logger.info("Retrieved role-name '" + roleName + "' from web.xml"); + } else { + logger.info("No security-role elements found in " + webXml); + } + } + + mappableAttributes = Collections.unmodifiableSet(new HashSet(roleNames)); + } + + /** + * @return Document for the specified InputStream + */ + private Document getDocument(InputStream aStream) { + Document doc; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setValidating(false); + DocumentBuilder db = factory.newDocumentBuilder(); + db.setEntityResolver(new MyEntityResolver()); + doc = db.parse(aStream); + return doc; + } catch (FactoryConfigurationError e) { + throw new RuntimeException("Unable to parse document object", e); + } catch (ParserConfigurationException e) { + throw new RuntimeException("Unable to parse document object", e); + } catch (SAXException e) { + throw new RuntimeException("Unable to parse document object", e); + } catch (IOException e) { + throw new RuntimeException("Unable to parse document object", e); + } finally { + try { + aStream.close(); + } catch (IOException e) { + logger.warn("Failed to close input stream for web.xml", e); + } + } + } + + /** + * We do not need to resolve external entities, so just return an empty + * String. + */ + private static final class MyEntityResolver implements EntityResolver { + public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { + return new InputSource(new StringReader("")); + } + } +} diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/websphere/WASUsernameAndGroupsExtractor.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/websphere/WASUsernameAndGroupsExtractor.java index 14677db22b..fc4fad1d77 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/websphere/WASUsernameAndGroupsExtractor.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/websphere/WASUsernameAndGroupsExtractor.java @@ -9,7 +9,6 @@ import java.util.List; * Only for internal use. * * @author Luke Taylor - * @version $Id$ * @since 3.0.0 */ interface WASUsernameAndGroupsExtractor { diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/websphere/WebSpherePreAuthenticatedWebAuthenticationDetailsSource.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/websphere/WebSpherePreAuthenticatedWebAuthenticationDetailsSource.java index bfb9857d2b..ed3b668432 100755 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/websphere/WebSpherePreAuthenticatedWebAuthenticationDetailsSource.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/websphere/WebSpherePreAuthenticatedWebAuthenticationDetailsSource.java @@ -6,10 +6,10 @@ import org.springframework.security.web.authentication.preauth.PreAuthenticatedG * This AuthenticationDetailsSource implementation, when configured with a MutableGrantedAuthoritiesContainer, * will set the pre-authenticated granted authorities based on the WebSphere groups for the current WebSphere * user, mapped using the configured Attributes2GrantedAuthoritiesMapper. - * + * * By default, this class is configured to build instances of the * PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails class. - * + * * @author Ruud Senden */ public class WebSpherePreAuthenticatedWebAuthenticationDetailsSource extends WebSpherePreAuthenticatedAuthenticationDetailsSource { diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/x509/SubjectDnX509PrincipalExtractor.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/x509/SubjectDnX509PrincipalExtractor.java index 13a1e06548..c9443236ca 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/x509/SubjectDnX509PrincipalExtractor.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/x509/SubjectDnX509PrincipalExtractor.java @@ -24,7 +24,6 @@ import java.util.regex.Matcher; * user name "jimi@hendrix.org" * * @author Luke Taylor - * @version $Id$ */ public class SubjectDnX509PrincipalExtractor implements X509PrincipalExtractor { //~ Instance fields ================================================================================================ diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/x509/X509AuthenticationFilter.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/x509/X509AuthenticationFilter.java index 1a2cbb23d6..37518e16f3 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/x509/X509AuthenticationFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/x509/X509AuthenticationFilter.java @@ -8,7 +8,6 @@ import org.springframework.security.web.authentication.preauth.AbstractPreAuthen /** * @author Luke Taylor - * @version $Id$ */ public class X509AuthenticationFilter extends AbstractPreAuthenticatedProcessingFilter { private X509PrincipalExtractor principalExtractor = new SubjectDnX509PrincipalExtractor(); diff --git a/web/src/main/java/org/springframework/security/web/authentication/preauth/x509/X509PrincipalExtractor.java b/web/src/main/java/org/springframework/security/web/authentication/preauth/x509/X509PrincipalExtractor.java index 7eda4b9fb9..cbe75ff20a 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/preauth/x509/X509PrincipalExtractor.java +++ b/web/src/main/java/org/springframework/security/web/authentication/preauth/x509/X509PrincipalExtractor.java @@ -6,7 +6,6 @@ import java.security.cert.X509Certificate; * Obtains the principal from an X509Certificate for use within the framework. * * @author Luke Taylor - * @version $Id$ */ public interface X509PrincipalExtractor { diff --git a/web/src/main/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServices.java b/web/src/main/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServices.java index 50d0fd1b32..9a2a016d34 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServices.java +++ b/web/src/main/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServices.java @@ -29,7 +29,6 @@ import org.springframework.util.StringUtils; * Base class for RememberMeServices implementations. * * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public abstract class AbstractRememberMeServices implements RememberMeServices, InitializingBean, LogoutHandler { diff --git a/web/src/main/java/org/springframework/security/web/authentication/rememberme/CookieTheftException.java b/web/src/main/java/org/springframework/security/web/authentication/rememberme/CookieTheftException.java index ee8cce4488..da962a3a05 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/rememberme/CookieTheftException.java +++ b/web/src/main/java/org/springframework/security/web/authentication/rememberme/CookieTheftException.java @@ -2,7 +2,6 @@ package org.springframework.security.web.authentication.rememberme; /** * @author Luke Taylor - * @version $Id$ */ public class CookieTheftException extends RememberMeAuthenticationException { public CookieTheftException(String message) { diff --git a/web/src/main/java/org/springframework/security/web/authentication/rememberme/InMemoryTokenRepositoryImpl.java b/web/src/main/java/org/springframework/security/web/authentication/rememberme/InMemoryTokenRepositoryImpl.java index 49eff9fcba..2961cafbdd 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/rememberme/InMemoryTokenRepositoryImpl.java +++ b/web/src/main/java/org/springframework/security/web/authentication/rememberme/InMemoryTokenRepositoryImpl.java @@ -11,7 +11,6 @@ import java.util.Map; * Simple PersistentTokenRepository implementation backed by a Map. Intended for testing only. * * @author Luke Taylor - * @version $Id$ */ public class InMemoryTokenRepositoryImpl implements PersistentTokenRepository { private Map seriesTokens = new HashMap(); diff --git a/web/src/main/java/org/springframework/security/web/authentication/rememberme/InvalidCookieException.java b/web/src/main/java/org/springframework/security/web/authentication/rememberme/InvalidCookieException.java index 122a4a1625..39238cd577 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/rememberme/InvalidCookieException.java +++ b/web/src/main/java/org/springframework/security/web/authentication/rememberme/InvalidCookieException.java @@ -5,7 +5,6 @@ package org.springframework.security.web.authentication.rememberme; * that a submitted cookie is of an invalid format or has expired. * * @author Luke Taylor - * @version $Id$ */ public class InvalidCookieException extends RememberMeAuthenticationException { public InvalidCookieException(String message) { diff --git a/web/src/main/java/org/springframework/security/web/authentication/rememberme/JdbcTokenRepositoryImpl.java b/web/src/main/java/org/springframework/security/web/authentication/rememberme/JdbcTokenRepositoryImpl.java index c353a3910b..7012b301b0 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/rememberme/JdbcTokenRepositoryImpl.java +++ b/web/src/main/java/org/springframework/security/web/authentication/rememberme/JdbcTokenRepositoryImpl.java @@ -17,7 +17,6 @@ import java.util.Date; * JDBC based persistent login token repository implementation. * * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public class JdbcTokenRepositoryImpl extends JdbcDaoSupport implements PersistentTokenRepository { diff --git a/web/src/main/java/org/springframework/security/web/authentication/rememberme/PersistentRememberMeToken.java b/web/src/main/java/org/springframework/security/web/authentication/rememberme/PersistentRememberMeToken.java index 4ef77afd8c..ebab6dabc0 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/rememberme/PersistentRememberMeToken.java +++ b/web/src/main/java/org/springframework/security/web/authentication/rememberme/PersistentRememberMeToken.java @@ -4,7 +4,6 @@ import java.util.Date; /** * @author Luke Taylor - * @version $Id$ */ public class PersistentRememberMeToken { private String username; diff --git a/web/src/main/java/org/springframework/security/web/authentication/rememberme/PersistentTokenBasedRememberMeServices.java b/web/src/main/java/org/springframework/security/web/authentication/rememberme/PersistentTokenBasedRememberMeServices.java index 03d6fb54f1..0442294da4 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/rememberme/PersistentTokenBasedRememberMeServices.java +++ b/web/src/main/java/org/springframework/security/web/authentication/rememberme/PersistentTokenBasedRememberMeServices.java @@ -35,7 +35,6 @@ import org.springframework.util.Assert; *

    * * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices { diff --git a/web/src/main/java/org/springframework/security/web/authentication/rememberme/PersistentTokenRepository.java b/web/src/main/java/org/springframework/security/web/authentication/rememberme/PersistentTokenRepository.java index c5b76be042..566cd783ba 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/rememberme/PersistentTokenRepository.java +++ b/web/src/main/java/org/springframework/security/web/authentication/rememberme/PersistentTokenRepository.java @@ -10,7 +10,6 @@ import java.util.Date; * @see InMemoryTokenRepositoryImpl * * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public interface PersistentTokenRepository { diff --git a/web/src/main/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationException.java b/web/src/main/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationException.java index ef1fdf6012..f8dda8661b 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationException.java +++ b/web/src/main/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationException.java @@ -4,7 +4,6 @@ import org.springframework.security.core.AuthenticationException; /** * @author Luke Taylor - * @version $Id$ */ public class RememberMeAuthenticationException extends AuthenticationException { diff --git a/web/src/main/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationFilter.java b/web/src/main/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationFilter.java index d6fe54502b..31d74e418f 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationFilter.java @@ -51,7 +51,6 @@ import org.springframework.web.filter.GenericFilterBean; * via an AuthenticationManager-specific application event.

    * * @author Ben Alex - * @version $Id$ */ public class RememberMeAuthenticationFilter extends GenericFilterBean implements ApplicationEventPublisherAware { diff --git a/web/src/main/java/org/springframework/security/web/authentication/rememberme/TokenBasedRememberMeServices.java b/web/src/main/java/org/springframework/security/web/authentication/rememberme/TokenBasedRememberMeServices.java index fabc8687c3..182aa771d7 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/rememberme/TokenBasedRememberMeServices.java +++ b/web/src/main/java/org/springframework/security/web/authentication/rememberme/TokenBasedRememberMeServices.java @@ -76,7 +76,6 @@ import java.util.Date; * * * @author Ben Alex - * @version $Id$ */ public class TokenBasedRememberMeServices extends AbstractRememberMeServices { diff --git a/web/src/main/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategy.java b/web/src/main/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategy.java index fbddf9c58a..73012a159a 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategy.java +++ b/web/src/main/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategy.java @@ -36,7 +36,6 @@ import org.springframework.util.Assert; * {@link AbstractAuthenticationProcessingFilter} (typically {@link UsernamePasswordAuthenticationFilter}). * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class ConcurrentSessionControlStrategy extends SessionFixationProtectionStrategy diff --git a/web/src/main/java/org/springframework/security/web/authentication/session/NullAuthenticatedSessionStrategy.java b/web/src/main/java/org/springframework/security/web/authentication/session/NullAuthenticatedSessionStrategy.java index e48548e1e8..c3524aae00 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/session/NullAuthenticatedSessionStrategy.java +++ b/web/src/main/java/org/springframework/security/web/authentication/session/NullAuthenticatedSessionStrategy.java @@ -8,7 +8,6 @@ import org.springframework.security.core.Authentication; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public final class NullAuthenticatedSessionStrategy implements SessionAuthenticationStrategy { diff --git a/web/src/main/java/org/springframework/security/web/authentication/session/SessionAuthenticationException.java b/web/src/main/java/org/springframework/security/web/authentication/session/SessionAuthenticationException.java index d38aeb8e99..a4989e4b11 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/session/SessionAuthenticationException.java +++ b/web/src/main/java/org/springframework/security/web/authentication/session/SessionAuthenticationException.java @@ -8,7 +8,6 @@ import org.springframework.security.core.AuthenticationException; * concurrently. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class SessionAuthenticationException extends AuthenticationException { diff --git a/web/src/main/java/org/springframework/security/web/authentication/session/SessionAuthenticationStrategy.java b/web/src/main/java/org/springframework/security/web/authentication/session/SessionAuthenticationStrategy.java index 383403c42d..f3b4d56e4e 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/session/SessionAuthenticationStrategy.java +++ b/web/src/main/java/org/springframework/security/web/authentication/session/SessionAuthenticationStrategy.java @@ -12,7 +12,6 @@ import org.springframework.security.core.Authentication; * attacks. * * @author Luke Taylor - * @version $Id$ * @since */ public interface SessionAuthenticationStrategy { diff --git a/web/src/main/java/org/springframework/security/web/authentication/session/SessionFixationProtectionStrategy.java b/web/src/main/java/org/springframework/security/web/authentication/session/SessionFixationProtectionStrategy.java index eb34c0b276..5f31e3fa54 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/session/SessionFixationProtectionStrategy.java +++ b/web/src/main/java/org/springframework/security/web/authentication/session/SessionFixationProtectionStrategy.java @@ -29,7 +29,6 @@ import org.springframework.security.web.savedrequest.DefaultSavedRequest; * If concurrent session control is in use, then a SessionRegistry must be injected. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class SessionFixationProtectionStrategy implements SessionAuthenticationStrategy { diff --git a/web/src/main/java/org/springframework/security/web/authentication/switchuser/AuthenticationSwitchUserEvent.java b/web/src/main/java/org/springframework/security/web/authentication/switchuser/AuthenticationSwitchUserEvent.java index 160a0c0165..b4361a91cd 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/switchuser/AuthenticationSwitchUserEvent.java +++ b/web/src/main/java/org/springframework/security/web/authentication/switchuser/AuthenticationSwitchUserEvent.java @@ -25,7 +25,6 @@ import org.springframework.security.core.userdetails.UserDetails; * Application event which indicates that a user context switch. * * @author Mark St.Godard - * @version $Id$ */ public class AuthenticationSwitchUserEvent extends AbstractAuthenticationEvent { //~ Instance fields ================================================================================================ diff --git a/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserAuthorityChanger.java b/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserAuthorityChanger.java index 4c2fdd5109..41ed21a75b 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserAuthorityChanger.java +++ b/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserAuthorityChanger.java @@ -13,7 +13,6 @@ import org.springframework.security.core.userdetails.UserDetails; *

    Configured against the {@link SwitchUserFilter}. * * @author Ben Alex - * @version $Id$ * */ public interface SwitchUserAuthorityChanger { diff --git a/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilter.java b/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilter.java index 5f9dc1b895..f9ef762404 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilter.java @@ -95,7 +95,6 @@ import org.springframework.web.filter.GenericFilterBean; * * * @author Mark St.Godard - * @version $Id$ * * @see org.springframework.security.web.authentication.switchuser.SwitchUserGrantedAuthority */ diff --git a/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserGrantedAuthority.java b/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserGrantedAuthority.java index 14fbe96ee4..a8d2a85089 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserGrantedAuthority.java +++ b/web/src/main/java/org/springframework/security/web/authentication/switchuser/SwitchUserGrantedAuthority.java @@ -24,7 +24,6 @@ import org.springframework.security.core.authority.GrantedAuthorityImpl; * the Authentication object of the original user to be used later when 'exiting' from a user switch.

    * * @author Mark St.Godard - * @version $Id$ * * @see org.springframework.security.web.authentication.switchuser.SwitchUserFilter */ diff --git a/web/src/main/java/org/springframework/security/web/authentication/switchuser/package.html b/web/src/main/java/org/springframework/security/web/authentication/switchuser/package.html index 75566609a2..0d0249588d 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/switchuser/package.html +++ b/web/src/main/java/org/springframework/security/web/authentication/switchuser/package.html @@ -1,5 +1,5 @@ - - -Provides HTTP-based "switch user" (su) capabilities. - - + + +Provides HTTP-based "switch user" (su) capabilities. + + diff --git a/web/src/main/java/org/springframework/security/web/authentication/ui/DefaultLoginPageGeneratingFilter.java b/web/src/main/java/org/springframework/security/web/authentication/ui/DefaultLoginPageGeneratingFilter.java index 7f30203837..a6bb07319c 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/ui/DefaultLoginPageGeneratingFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/ui/DefaultLoginPageGeneratingFilter.java @@ -23,7 +23,6 @@ import org.springframework.web.filter.GenericFilterBean; * Will only work if a redirect is used to the login page. * * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean { diff --git a/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPoint.java index 5920cf8412..9b7e59fa4e 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPoint.java @@ -36,7 +36,6 @@ import org.springframework.util.Assert; * the browser its credentials are no longer authorized, causing it to prompt the user to login again. * * @author Ben Alex - * @version $Id$ */ public class BasicAuthenticationEntryPoint implements AuthenticationEntryPoint, InitializingBean { //~ Instance fields ================================================================================================ diff --git a/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilter.java b/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilter.java index 74fadc5494..6418564abd 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilter.java @@ -83,7 +83,6 @@ import org.springframework.web.filter.GenericFilterBean; * they will be authenticated using the remember-me mechanism. * * @author Ben Alex - * @version $Id$ */ public class BasicAuthenticationFilter extends GenericFilterBean { diff --git a/web/src/main/java/org/springframework/security/web/authentication/www/DigestAuthenticationEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/www/DigestAuthenticationEntryPoint.java index 992708d453..7729b4a239 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/www/DigestAuthenticationEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/www/DigestAuthenticationEntryPoint.java @@ -39,7 +39,6 @@ import org.springframework.security.web.AuthenticationEntryPoint; * automatically renegotiate with a new nonce value (ie without presenting a new password dialog box to the user).

    * * @author Ben Alex - * @version $Id$ */ public class DigestAuthenticationEntryPoint implements AuthenticationEntryPoint, InitializingBean, Ordered { //~ Static fields/initializers ===================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/authentication/www/NonceExpiredException.java b/web/src/main/java/org/springframework/security/web/authentication/www/NonceExpiredException.java index ddb8b43268..f6e83b9dc3 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/www/NonceExpiredException.java +++ b/web/src/main/java/org/springframework/security/web/authentication/www/NonceExpiredException.java @@ -22,7 +22,6 @@ import org.springframework.security.core.AuthenticationException; * Thrown if an authentication request is rejected because the digest nonce has expired. * * @author Ben Alex - * @version $Id$ */ public class NonceExpiredException extends AuthenticationException { //~ Constructors =================================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/context/HttpRequestResponseHolder.java b/web/src/main/java/org/springframework/security/web/context/HttpRequestResponseHolder.java index 6cc1b74783..64903af3b2 100644 --- a/web/src/main/java/org/springframework/security/web/context/HttpRequestResponseHolder.java +++ b/web/src/main/java/org/springframework/security/web/context/HttpRequestResponseHolder.java @@ -9,7 +9,6 @@ import javax.servlet.http.HttpServletResponse; * value. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class HttpRequestResponseHolder { diff --git a/web/src/main/java/org/springframework/security/web/context/HttpSessionContextIntegrationFilter.java b/web/src/main/java/org/springframework/security/web/context/HttpSessionContextIntegrationFilter.java index 725782632b..6b807e5b9b 100644 --- a/web/src/main/java/org/springframework/security/web/context/HttpSessionContextIntegrationFilter.java +++ b/web/src/main/java/org/springframework/security/web/context/HttpSessionContextIntegrationFilter.java @@ -86,7 +86,6 @@ import org.springframework.security.core.context.SecurityContextImpl; * * @deprecated Use SecurityContextPersistenceFilter instead. * - * @version $Id$ */ public class HttpSessionContextIntegrationFilter extends SecurityContextPersistenceFilter implements InitializingBean { //~ Static fields/initializers ===================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/context/HttpSessionSecurityContextRepository.java b/web/src/main/java/org/springframework/security/web/context/HttpSessionSecurityContextRepository.java index c5e489dc37..41f1c83a42 100644 --- a/web/src/main/java/org/springframework/security/web/context/HttpSessionSecurityContextRepository.java +++ b/web/src/main/java/org/springframework/security/web/context/HttpSessionSecurityContextRepository.java @@ -49,7 +49,6 @@ import org.springframework.util.ReflectionUtils; * between web requests. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class HttpSessionSecurityContextRepository implements SecurityContextRepository { diff --git a/web/src/main/java/org/springframework/security/web/context/SaveContextOnUpdateOrErrorResponseWrapper.java b/web/src/main/java/org/springframework/security/web/context/SaveContextOnUpdateOrErrorResponseWrapper.java index 5bac8a19bb..52f39ea4cc 100644 --- a/web/src/main/java/org/springframework/security/web/context/SaveContextOnUpdateOrErrorResponseWrapper.java +++ b/web/src/main/java/org/springframework/security/web/context/SaveContextOnUpdateOrErrorResponseWrapper.java @@ -19,7 +19,6 @@ import org.springframework.security.core.context.SecurityContextHolder; * * @author Luke Taylor * @author Marten Algesten - * @version $Id$ * @since 3.0 */ public abstract class SaveContextOnUpdateOrErrorResponseWrapper extends HttpServletResponseWrapper { diff --git a/web/src/main/java/org/springframework/security/web/context/SecurityContextPersistenceFilter.java b/web/src/main/java/org/springframework/security/web/context/SecurityContextPersistenceFilter.java index b9958a6148..8ecc542be8 100644 --- a/web/src/main/java/org/springframework/security/web/context/SecurityContextPersistenceFilter.java +++ b/web/src/main/java/org/springframework/security/web/context/SecurityContextPersistenceFilter.java @@ -36,7 +36,6 @@ import org.springframework.web.filter.GenericFilterBean; * the filter chain executes (the default is false, as this is resource intensive and not recommended). * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class SecurityContextPersistenceFilter extends GenericFilterBean { diff --git a/web/src/main/java/org/springframework/security/web/context/SecurityContextRepository.java b/web/src/main/java/org/springframework/security/web/context/SecurityContextRepository.java index 8952c44686..29c9b2805b 100644 --- a/web/src/main/java/org/springframework/security/web/context/SecurityContextRepository.java +++ b/web/src/main/java/org/springframework/security/web/context/SecurityContextRepository.java @@ -16,7 +16,6 @@ import org.springframework.security.core.context.SecurityContext; * be used to store the context. * * @author Luke Taylor - * @version $Id$ * @since 3.0 * * @see SecurityContextPersistenceFilter diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java b/web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java index e7c0b58054..10c39bbb38 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java @@ -1,341 +1,340 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.web.savedrequest; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.TreeMap; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.security.web.PortResolver; -import org.springframework.security.web.util.UrlUtils; -import org.springframework.util.Assert; - - -/** - * Represents central information from a HttpServletRequest.

    This class is used by {@link - * org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter} and {@link org.springframework.security.web.savedrequest.SavedRequestAwareWrapper} to - * reproduce the request after successful authentication. An instance of this class is stored at the time of an - * authentication exception by {@link org.springframework.security.web.access.ExceptionTranslationFilter}.

    - *

    IMPLEMENTATION NOTE: It is assumed that this object is accessed only from the context of a single - * thread, so no synchronization around internal collection classes is performed.

    - *

    This class is based on code in Apache Tomcat.

    - * - * @author Craig McClanahan - * @author Andrey Grebnev - * @author Ben Alex - * @version $Id$ - */ -public class DefaultSavedRequest implements SavedRequest { - //~ Static fields/initializers ===================================================================================== - - protected static final Log logger = LogFactory.getLog(DefaultSavedRequest.class); - - public static final String SPRING_SECURITY_SAVED_REQUEST_KEY = "SPRING_SECURITY_SAVED_REQUEST_KEY"; - - //~ Instance fields ================================================================================================ - - private ArrayList cookies = new ArrayList(); - private ArrayList locales = new ArrayList(); - private Map> headers = new TreeMap>(String.CASE_INSENSITIVE_ORDER); - private Map parameters = new TreeMap(String.CASE_INSENSITIVE_ORDER); - private String contextPath; - private String method; - private String pathInfo; - private String queryString; - private String requestURI; - private String requestURL; - private String scheme; - private String serverName; - private String servletPath; - private int serverPort; - - //~ Constructors =================================================================================================== - - @SuppressWarnings("unchecked") - public DefaultSavedRequest(HttpServletRequest request, PortResolver portResolver) { - Assert.notNull(request, "Request required"); - Assert.notNull(portResolver, "PortResolver required"); - - // Cookies - Cookie[] cookies = request.getCookies(); - - if (cookies != null) { - for (int i = 0; i < cookies.length; i++) { - this.addCookie(cookies[i]); - } - } - - // Headers - Enumeration names = request.getHeaderNames(); - - while (names.hasMoreElements()) { - String name = names.nextElement(); - Enumeration values = request.getHeaders(name); - - while (values.hasMoreElements()) { - this.addHeader(name, values.nextElement()); - } - } - - // Locales - Enumeration locales = request.getLocales(); - - while (locales.hasMoreElements()) { - Locale locale = (Locale) locales.nextElement(); - this.addLocale(locale); - } - - // Parameters - Map parameters = request.getParameterMap(); - - for(String paramName : parameters.keySet()) { - Object paramValues = parameters.get(paramName); - if (paramValues instanceof String[]) { - this.addParameter(paramName, (String[]) paramValues); - } else { - if (logger.isWarnEnabled()) { - logger.warn("ServletRequest.getParameterMap() returned non-String array"); - } - } - } - - // Primitives - this.method = request.getMethod(); - this.pathInfo = request.getPathInfo(); - this.queryString = request.getQueryString(); - this.requestURI = request.getRequestURI(); - this.serverPort = portResolver.getServerPort(request); - this.requestURL = request.getRequestURL().toString(); - this.scheme = request.getScheme(); - this.serverName = request.getServerName(); - this.contextPath = request.getContextPath(); - this.servletPath = request.getServletPath(); - } - - //~ Methods ======================================================================================================== - - private void addCookie(Cookie cookie) { - cookies.add(new SavedCookie(cookie)); - } - - private void addHeader(String name, String value) { - List values = headers.get(name); - - if (values == null) { - values = new ArrayList(); - headers.put(name, values); - } - - values.add(value); - } - - private void addLocale(Locale locale) { - locales.add(locale); - } - - private void addParameter(String name, String[] values) { - parameters.put(name, values); - } - - /** - * Determines if the current request matches the DefaultSavedRequest. - *

    - * All URL arguments are considered but not cookies, locales, headers or parameters. - *

    - * - */ - public boolean doesRequestMatch(HttpServletRequest request, PortResolver portResolver) { - - if (!propertyEquals("pathInfo", this.pathInfo, request.getPathInfo())) { - return false; - } - - if (!propertyEquals("queryString", this.queryString, request.getQueryString())) { - return false; - } - - if (!propertyEquals("requestURI", this.requestURI, request.getRequestURI())) { - return false; - } - - if (!"GET".equals(request.getMethod()) && "GET".equals(method)) { - // A save GET should not match an incoming non-GET method - return false; - } - - if (!propertyEquals("serverPort", new Integer(this.serverPort), new Integer(portResolver.getServerPort(request)))) - { - return false; - } - - if (!propertyEquals("requestURL", this.requestURL, request.getRequestURL().toString())) { - return false; - } - - if (!propertyEquals("scheme", this.scheme, request.getScheme())) { - return false; - } - - if (!propertyEquals("serverName", this.serverName, request.getServerName())) { - return false; - } - - if (!propertyEquals("contextPath", this.contextPath, request.getContextPath())) { - return false; - } - - if (!propertyEquals("servletPath", this.servletPath, request.getServletPath())) { - return false; - } - - return true; - } - - public String getContextPath() { - return contextPath; - } - - public List getCookies() { - List cookieList = new ArrayList(cookies.size()); - - for (SavedCookie savedCookie : cookies) { - cookieList.add(savedCookie.getCookie()); - } - - return cookieList; - } - - /** - * Indicates the URL that the user agent used for this request. - * - * @return the full URL of this request - */ - public String getRedirectUrl() { - return UrlUtils.buildFullRequestUrl(scheme, serverName, serverPort, requestURI, queryString); - } - - public Collection getHeaderNames() { - return headers.keySet(); - } - - public List getHeaderValues(String name) { - List values = headers.get(name); - - if (values == null) { - return Collections.emptyList(); - } - - return values; - } - - public List getLocales() { - return locales; - } - - public String getMethod() { - return method; - } - - public Map getParameterMap() { - return parameters; - } - - public Collection getParameterNames() { - return parameters.keySet(); - } - - public String[] getParameterValues(String name) { - return ((String[]) parameters.get(name)); - } - - public String getPathInfo() { - return pathInfo; - } - - public String getQueryString() { - return (this.queryString); - } - - public String getRequestURI() { - return (this.requestURI); - } - - public String getRequestURL() { - return requestURL; - } - - public String getScheme() { - return scheme; - } - - public String getServerName() { - return serverName; - } - - public int getServerPort() { - return serverPort; - } - - public String getServletPath() { - return servletPath; - } - - private boolean propertyEquals(String log, Object arg1, Object arg2) { - if ((arg1 == null) && (arg2 == null)) { - if (logger.isDebugEnabled()) { - logger.debug(log + ": both null (property equals)"); - } - - return true; - } - - if (((arg1 == null) && (arg2 != null)) || ((arg1 != null) && (arg2 == null))) { - if (logger.isDebugEnabled()) { - logger.debug(log + ": arg1=" + arg1 + "; arg2=" + arg2 + " (property not equals)"); - } - - return false; - } - - if (arg1.equals(arg2)) { - if (logger.isDebugEnabled()) { - logger.debug(log + ": arg1=" + arg1 + "; arg2=" + arg2 + " (property equals)"); - } - - return true; - } else { - if (logger.isDebugEnabled()) { - logger.debug(log + ": arg1=" + arg1 + "; arg2=" + arg2 + " (property not equals)"); - } - - return false; - } - } - - public String toString() { - return "DefaultSavedRequest[" + getRedirectUrl() + "]"; - } -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.web.savedrequest; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.TreeMap; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.security.web.PortResolver; +import org.springframework.security.web.util.UrlUtils; +import org.springframework.util.Assert; + + +/** + * Represents central information from a HttpServletRequest.

    This class is used by {@link + * org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter} and {@link org.springframework.security.web.savedrequest.SavedRequestAwareWrapper} to + * reproduce the request after successful authentication. An instance of this class is stored at the time of an + * authentication exception by {@link org.springframework.security.web.access.ExceptionTranslationFilter}.

    + *

    IMPLEMENTATION NOTE: It is assumed that this object is accessed only from the context of a single + * thread, so no synchronization around internal collection classes is performed.

    + *

    This class is based on code in Apache Tomcat.

    + * + * @author Craig McClanahan + * @author Andrey Grebnev + * @author Ben Alex + */ +public class DefaultSavedRequest implements SavedRequest { + //~ Static fields/initializers ===================================================================================== + + protected static final Log logger = LogFactory.getLog(DefaultSavedRequest.class); + + public static final String SPRING_SECURITY_SAVED_REQUEST_KEY = "SPRING_SECURITY_SAVED_REQUEST_KEY"; + + //~ Instance fields ================================================================================================ + + private ArrayList cookies = new ArrayList(); + private ArrayList locales = new ArrayList(); + private Map> headers = new TreeMap>(String.CASE_INSENSITIVE_ORDER); + private Map parameters = new TreeMap(String.CASE_INSENSITIVE_ORDER); + private String contextPath; + private String method; + private String pathInfo; + private String queryString; + private String requestURI; + private String requestURL; + private String scheme; + private String serverName; + private String servletPath; + private int serverPort; + + //~ Constructors =================================================================================================== + + @SuppressWarnings("unchecked") + public DefaultSavedRequest(HttpServletRequest request, PortResolver portResolver) { + Assert.notNull(request, "Request required"); + Assert.notNull(portResolver, "PortResolver required"); + + // Cookies + Cookie[] cookies = request.getCookies(); + + if (cookies != null) { + for (int i = 0; i < cookies.length; i++) { + this.addCookie(cookies[i]); + } + } + + // Headers + Enumeration names = request.getHeaderNames(); + + while (names.hasMoreElements()) { + String name = names.nextElement(); + Enumeration values = request.getHeaders(name); + + while (values.hasMoreElements()) { + this.addHeader(name, values.nextElement()); + } + } + + // Locales + Enumeration locales = request.getLocales(); + + while (locales.hasMoreElements()) { + Locale locale = (Locale) locales.nextElement(); + this.addLocale(locale); + } + + // Parameters + Map parameters = request.getParameterMap(); + + for(String paramName : parameters.keySet()) { + Object paramValues = parameters.get(paramName); + if (paramValues instanceof String[]) { + this.addParameter(paramName, (String[]) paramValues); + } else { + if (logger.isWarnEnabled()) { + logger.warn("ServletRequest.getParameterMap() returned non-String array"); + } + } + } + + // Primitives + this.method = request.getMethod(); + this.pathInfo = request.getPathInfo(); + this.queryString = request.getQueryString(); + this.requestURI = request.getRequestURI(); + this.serverPort = portResolver.getServerPort(request); + this.requestURL = request.getRequestURL().toString(); + this.scheme = request.getScheme(); + this.serverName = request.getServerName(); + this.contextPath = request.getContextPath(); + this.servletPath = request.getServletPath(); + } + + //~ Methods ======================================================================================================== + + private void addCookie(Cookie cookie) { + cookies.add(new SavedCookie(cookie)); + } + + private void addHeader(String name, String value) { + List values = headers.get(name); + + if (values == null) { + values = new ArrayList(); + headers.put(name, values); + } + + values.add(value); + } + + private void addLocale(Locale locale) { + locales.add(locale); + } + + private void addParameter(String name, String[] values) { + parameters.put(name, values); + } + + /** + * Determines if the current request matches the DefaultSavedRequest. + *

    + * All URL arguments are considered but not cookies, locales, headers or parameters. + *

    + * + */ + public boolean doesRequestMatch(HttpServletRequest request, PortResolver portResolver) { + + if (!propertyEquals("pathInfo", this.pathInfo, request.getPathInfo())) { + return false; + } + + if (!propertyEquals("queryString", this.queryString, request.getQueryString())) { + return false; + } + + if (!propertyEquals("requestURI", this.requestURI, request.getRequestURI())) { + return false; + } + + if (!"GET".equals(request.getMethod()) && "GET".equals(method)) { + // A save GET should not match an incoming non-GET method + return false; + } + + if (!propertyEquals("serverPort", new Integer(this.serverPort), new Integer(portResolver.getServerPort(request)))) + { + return false; + } + + if (!propertyEquals("requestURL", this.requestURL, request.getRequestURL().toString())) { + return false; + } + + if (!propertyEquals("scheme", this.scheme, request.getScheme())) { + return false; + } + + if (!propertyEquals("serverName", this.serverName, request.getServerName())) { + return false; + } + + if (!propertyEquals("contextPath", this.contextPath, request.getContextPath())) { + return false; + } + + if (!propertyEquals("servletPath", this.servletPath, request.getServletPath())) { + return false; + } + + return true; + } + + public String getContextPath() { + return contextPath; + } + + public List getCookies() { + List cookieList = new ArrayList(cookies.size()); + + for (SavedCookie savedCookie : cookies) { + cookieList.add(savedCookie.getCookie()); + } + + return cookieList; + } + + /** + * Indicates the URL that the user agent used for this request. + * + * @return the full URL of this request + */ + public String getRedirectUrl() { + return UrlUtils.buildFullRequestUrl(scheme, serverName, serverPort, requestURI, queryString); + } + + public Collection getHeaderNames() { + return headers.keySet(); + } + + public List getHeaderValues(String name) { + List values = headers.get(name); + + if (values == null) { + return Collections.emptyList(); + } + + return values; + } + + public List getLocales() { + return locales; + } + + public String getMethod() { + return method; + } + + public Map getParameterMap() { + return parameters; + } + + public Collection getParameterNames() { + return parameters.keySet(); + } + + public String[] getParameterValues(String name) { + return ((String[]) parameters.get(name)); + } + + public String getPathInfo() { + return pathInfo; + } + + public String getQueryString() { + return (this.queryString); + } + + public String getRequestURI() { + return (this.requestURI); + } + + public String getRequestURL() { + return requestURL; + } + + public String getScheme() { + return scheme; + } + + public String getServerName() { + return serverName; + } + + public int getServerPort() { + return serverPort; + } + + public String getServletPath() { + return servletPath; + } + + private boolean propertyEquals(String log, Object arg1, Object arg2) { + if ((arg1 == null) && (arg2 == null)) { + if (logger.isDebugEnabled()) { + logger.debug(log + ": both null (property equals)"); + } + + return true; + } + + if (((arg1 == null) && (arg2 != null)) || ((arg1 != null) && (arg2 == null))) { + if (logger.isDebugEnabled()) { + logger.debug(log + ": arg1=" + arg1 + "; arg2=" + arg2 + " (property not equals)"); + } + + return false; + } + + if (arg1.equals(arg2)) { + if (logger.isDebugEnabled()) { + logger.debug(log + ": arg1=" + arg1 + "; arg2=" + arg2 + " (property equals)"); + } + + return true; + } else { + if (logger.isDebugEnabled()) { + logger.debug(log + ": arg1=" + arg1 + "; arg2=" + arg2 + " (property not equals)"); + } + + return false; + } + } + + public String toString() { + return "DefaultSavedRequest[" + getRedirectUrl() + "]"; + } +} diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/Enumerator.java b/web/src/main/java/org/springframework/security/web/savedrequest/Enumerator.java index 98bd7dd527..8313d41803 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/Enumerator.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/Enumerator.java @@ -1,139 +1,138 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.web.savedrequest; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; - - -/** - *

    Adapter that wraps an Enumeration around a Java 2 collection Iterator.

    - *

    Constructors are provided to easily create such wrappers.

    - *

    This class is based on code in Apache Tomcat.

    - * - * @author Craig McClanahan - * @author Andrey Grebnev - * @version $Id$ - */ -public class Enumerator implements Enumeration { - //~ Instance fields ================================================================================================ - - /** - * The Iterator over which the Enumeration represented by this class actually operates. - */ - private Iterator iterator = null; - - //~ Constructors =================================================================================================== - - /** - * Return an Enumeration over the values of the specified Collection. - * - * @param collection Collection whose values should be enumerated - */ - public Enumerator(Collection collection) { - this(collection.iterator()); - } - - /** - * Return an Enumeration over the values of the specified Collection. - * - * @param collection Collection whose values should be enumerated - * @param clone true to clone iterator - */ - public Enumerator(Collection collection, boolean clone) { - this(collection.iterator(), clone); - } - - /** - * Return an Enumeration over the values returned by the specified - * Iterator. - * - * @param iterator Iterator to be wrapped - */ - public Enumerator(Iterator iterator) { - this.iterator = iterator; - } - - /** - * Return an Enumeration over the values returned by the specified - * Iterator. - * - * @param iterator Iterator to be wrapped - * @param clone true to clone iterator - */ - public Enumerator(Iterator iterator, boolean clone) { - - if (!clone) { - this.iterator = iterator; - } else { - List list = new ArrayList(); - - while (iterator.hasNext()) { - list.add(iterator.next()); - } - - this.iterator = list.iterator(); - } - } - - /** - * Return an Enumeration over the values of the specified Map. - * - * @param map Map whose values should be enumerated - */ - public Enumerator(Map map) { - this(map.values().iterator()); - } - - /** - * Return an Enumeration over the values of the specified Map. - * - * @param map Map whose values should be enumerated - * @param clone true to clone iterator - */ - public Enumerator(Map map, boolean clone) { - this(map.values().iterator(), clone); - } - - //~ Methods ======================================================================================================== - - /** - * Tests if this enumeration contains more elements. - * - * @return true if and only if this enumeration object contains at least one more element to provide, - * false otherwise - */ - public boolean hasMoreElements() { - return (iterator.hasNext()); - } - - /** - * Returns the next element of this enumeration if this enumeration has at least one more element to - * provide. - * - * @return the next element of this enumeration - * - * @exception NoSuchElementException if no more elements exist - */ - public T nextElement() throws NoSuchElementException { - return (iterator.next()); - } -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.web.savedrequest; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; + + +/** + *

    Adapter that wraps an Enumeration around a Java 2 collection Iterator.

    + *

    Constructors are provided to easily create such wrappers.

    + *

    This class is based on code in Apache Tomcat.

    + * + * @author Craig McClanahan + * @author Andrey Grebnev + */ +public class Enumerator implements Enumeration { + //~ Instance fields ================================================================================================ + + /** + * The Iterator over which the Enumeration represented by this class actually operates. + */ + private Iterator iterator = null; + + //~ Constructors =================================================================================================== + + /** + * Return an Enumeration over the values of the specified Collection. + * + * @param collection Collection whose values should be enumerated + */ + public Enumerator(Collection collection) { + this(collection.iterator()); + } + + /** + * Return an Enumeration over the values of the specified Collection. + * + * @param collection Collection whose values should be enumerated + * @param clone true to clone iterator + */ + public Enumerator(Collection collection, boolean clone) { + this(collection.iterator(), clone); + } + + /** + * Return an Enumeration over the values returned by the specified + * Iterator. + * + * @param iterator Iterator to be wrapped + */ + public Enumerator(Iterator iterator) { + this.iterator = iterator; + } + + /** + * Return an Enumeration over the values returned by the specified + * Iterator. + * + * @param iterator Iterator to be wrapped + * @param clone true to clone iterator + */ + public Enumerator(Iterator iterator, boolean clone) { + + if (!clone) { + this.iterator = iterator; + } else { + List list = new ArrayList(); + + while (iterator.hasNext()) { + list.add(iterator.next()); + } + + this.iterator = list.iterator(); + } + } + + /** + * Return an Enumeration over the values of the specified Map. + * + * @param map Map whose values should be enumerated + */ + public Enumerator(Map map) { + this(map.values().iterator()); + } + + /** + * Return an Enumeration over the values of the specified Map. + * + * @param map Map whose values should be enumerated + * @param clone true to clone iterator + */ + public Enumerator(Map map, boolean clone) { + this(map.values().iterator(), clone); + } + + //~ Methods ======================================================================================================== + + /** + * Tests if this enumeration contains more elements. + * + * @return true if and only if this enumeration object contains at least one more element to provide, + * false otherwise + */ + public boolean hasMoreElements() { + return (iterator.hasNext()); + } + + /** + * Returns the next element of this enumeration if this enumeration has at least one more element to + * provide. + * + * @return the next element of this enumeration + * + * @exception NoSuchElementException if no more elements exist + */ + public T nextElement() throws NoSuchElementException { + return (iterator.next()); + } +} diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/FastHttpDateFormat.java b/web/src/main/java/org/springframework/security/web/savedrequest/FastHttpDateFormat.java index 4938ac31d9..136d2a82a0 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/FastHttpDateFormat.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/FastHttpDateFormat.java @@ -1,221 +1,220 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.web.savedrequest; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; - -import java.util.Date; -import java.util.HashMap; -import java.util.Locale; -import java.util.TimeZone; - - -/** - * Utility class to generate HTTP dates. - *

    - * This class is based on code in Apache Tomcat. - * - * @author Remy Maucherat - * @author Andrey Grebnev - * @version $Id$ - */ -public class FastHttpDateFormat { - //~ Static fields/initializers ===================================================================================== - - /** HTTP date format. */ - protected static final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); - - /** The set of SimpleDateFormat formats to use in getDateHeader(). */ - protected static final SimpleDateFormat[] formats = { - new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US), - new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US), - new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US) - }; - - /** GMT time zone - all HTTP dates are on GMT */ - protected static final TimeZone gmtZone = TimeZone.getTimeZone("GMT"); - - static { - format.setTimeZone(gmtZone); - - formats[0].setTimeZone(gmtZone); - formats[1].setTimeZone(gmtZone); - formats[2].setTimeZone(gmtZone); - } - - /** Instant on which the currentDate object was generated. */ - protected static long currentDateGenerated = 0L; - - /** Current formatted date. */ - protected static String currentDate = null; - - /** Formatter cache. */ - protected static final HashMap formatCache = new HashMap(); - - /** Parser cache. */ - protected static final HashMap parseCache = new HashMap(); - - //~ Methods ======================================================================================================== - - /** - * Formats a specified date to HTTP format. If local format is not null, it's used instead. - * - * @param value Date value to format - * @param threadLocalformat The format to use (or null -- then HTTP format will be used) - * - * @return Formatted date - */ - public static final String formatDate(long value, DateFormat threadLocalformat) { - String cachedDate = null; - Long longValue = new Long(value); - - try { - cachedDate = formatCache.get(longValue); - } catch (Exception e) {} - - if (cachedDate != null) { - return cachedDate; - } - - String newDate = null; - Date dateValue = new Date(value); - - if (threadLocalformat != null) { - newDate = threadLocalformat.format(dateValue); - - synchronized (formatCache) { - updateCache(formatCache, longValue, newDate); - } - } else { - synchronized (formatCache) { - newDate = format.format(dateValue); - updateCache(formatCache, longValue, newDate); - } - } - - return newDate; - } - - /** - * Gets the current date in HTTP format. - * - * @return Current date in HTTP format - */ - public static final String getCurrentDate() { - long now = System.currentTimeMillis(); - - if ((now - currentDateGenerated) > 1000) { - synchronized (format) { - if ((now - currentDateGenerated) > 1000) { - currentDateGenerated = now; - currentDate = format.format(new Date(now)); - } - } - } - - return currentDate; - } - - /** - * Parses date with given formatters. - * - * @param value The string to parse - * @param formats Array of formats to use - * - * @return Parsed date (or null if no formatter mached) - */ - private static Long internalParseDate(String value, DateFormat[] formats) { - Date date = null; - - for (int i = 0; (date == null) && (i < formats.length); i++) { - try { - date = formats[i].parse(value); - } catch (ParseException e) { - ; - } - } - - if (date == null) { - return null; - } - - return new Long(date.getTime()); - } - - /** - * Tries to parse the given date as an HTTP date. If local format list is not null, it's used - * instead. - * - * @param value The string to parse - * @param threadLocalformats Array of formats to use for parsing. If null, HTTP formats are used. - * - * @return Parsed date (or -1 if error occurred) - */ - public static final long parseDate(String value, DateFormat[] threadLocalformats) { - Long cachedDate = null; - - try { - cachedDate = (Long) parseCache.get(value); - } catch (Exception e) {} - - if (cachedDate != null) { - return cachedDate.longValue(); - } - - Long date = null; - - if (threadLocalformats != null) { - date = internalParseDate(value, threadLocalformats); - - synchronized (parseCache) { - updateCache(parseCache, value, date); - } - } else { - synchronized (parseCache) { - date = internalParseDate(value, formats); - updateCache(parseCache, value, date); - } - } - - if (date == null) { - return (-1L); - } else { - return date.longValue(); - } - } - - /** - * Updates cache. - * - * @param cache Cache to be updated - * @param key Key to be updated - * @param value New value - */ - @SuppressWarnings("unchecked") - private static void updateCache(HashMap cache, Object key, Object value) { - if (value == null) { - return; - } - - if (cache.size() > 1000) { - cache.clear(); - } - - cache.put(key, value); - } -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.web.savedrequest; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; + +import java.util.Date; +import java.util.HashMap; +import java.util.Locale; +import java.util.TimeZone; + + +/** + * Utility class to generate HTTP dates. + *

    + * This class is based on code in Apache Tomcat. + * + * @author Remy Maucherat + * @author Andrey Grebnev + */ +public class FastHttpDateFormat { + //~ Static fields/initializers ===================================================================================== + + /** HTTP date format. */ + protected static final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); + + /** The set of SimpleDateFormat formats to use in getDateHeader(). */ + protected static final SimpleDateFormat[] formats = { + new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US), + new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US), + new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US) + }; + + /** GMT time zone - all HTTP dates are on GMT */ + protected static final TimeZone gmtZone = TimeZone.getTimeZone("GMT"); + + static { + format.setTimeZone(gmtZone); + + formats[0].setTimeZone(gmtZone); + formats[1].setTimeZone(gmtZone); + formats[2].setTimeZone(gmtZone); + } + + /** Instant on which the currentDate object was generated. */ + protected static long currentDateGenerated = 0L; + + /** Current formatted date. */ + protected static String currentDate = null; + + /** Formatter cache. */ + protected static final HashMap formatCache = new HashMap(); + + /** Parser cache. */ + protected static final HashMap parseCache = new HashMap(); + + //~ Methods ======================================================================================================== + + /** + * Formats a specified date to HTTP format. If local format is not null, it's used instead. + * + * @param value Date value to format + * @param threadLocalformat The format to use (or null -- then HTTP format will be used) + * + * @return Formatted date + */ + public static final String formatDate(long value, DateFormat threadLocalformat) { + String cachedDate = null; + Long longValue = new Long(value); + + try { + cachedDate = formatCache.get(longValue); + } catch (Exception e) {} + + if (cachedDate != null) { + return cachedDate; + } + + String newDate = null; + Date dateValue = new Date(value); + + if (threadLocalformat != null) { + newDate = threadLocalformat.format(dateValue); + + synchronized (formatCache) { + updateCache(formatCache, longValue, newDate); + } + } else { + synchronized (formatCache) { + newDate = format.format(dateValue); + updateCache(formatCache, longValue, newDate); + } + } + + return newDate; + } + + /** + * Gets the current date in HTTP format. + * + * @return Current date in HTTP format + */ + public static final String getCurrentDate() { + long now = System.currentTimeMillis(); + + if ((now - currentDateGenerated) > 1000) { + synchronized (format) { + if ((now - currentDateGenerated) > 1000) { + currentDateGenerated = now; + currentDate = format.format(new Date(now)); + } + } + } + + return currentDate; + } + + /** + * Parses date with given formatters. + * + * @param value The string to parse + * @param formats Array of formats to use + * + * @return Parsed date (or null if no formatter mached) + */ + private static Long internalParseDate(String value, DateFormat[] formats) { + Date date = null; + + for (int i = 0; (date == null) && (i < formats.length); i++) { + try { + date = formats[i].parse(value); + } catch (ParseException e) { + ; + } + } + + if (date == null) { + return null; + } + + return new Long(date.getTime()); + } + + /** + * Tries to parse the given date as an HTTP date. If local format list is not null, it's used + * instead. + * + * @param value The string to parse + * @param threadLocalformats Array of formats to use for parsing. If null, HTTP formats are used. + * + * @return Parsed date (or -1 if error occurred) + */ + public static final long parseDate(String value, DateFormat[] threadLocalformats) { + Long cachedDate = null; + + try { + cachedDate = (Long) parseCache.get(value); + } catch (Exception e) {} + + if (cachedDate != null) { + return cachedDate.longValue(); + } + + Long date = null; + + if (threadLocalformats != null) { + date = internalParseDate(value, threadLocalformats); + + synchronized (parseCache) { + updateCache(parseCache, value, date); + } + } else { + synchronized (parseCache) { + date = internalParseDate(value, formats); + updateCache(parseCache, value, date); + } + } + + if (date == null) { + return (-1L); + } else { + return date.longValue(); + } + } + + /** + * Updates cache. + * + * @param cache Cache to be updated + * @param key Key to be updated + * @param value New value + */ + @SuppressWarnings("unchecked") + private static void updateCache(HashMap cache, Object key, Object value) { + if (value == null) { + return; + } + + if (cache.size() > 1000) { + cache.clear(); + } + + cache.put(key, value); + } +} diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/HttpSessionRequestCache.java b/web/src/main/java/org/springframework/security/web/savedrequest/HttpSessionRequestCache.java index 6a76489aa2..d7582aaaad 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/HttpSessionRequestCache.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/HttpSessionRequestCache.java @@ -15,7 +15,6 @@ import org.springframework.security.web.PortResolverImpl; * The {@link DefaultSavedRequest} class is used as the implementation. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class HttpSessionRequestCache implements RequestCache { diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/NullRequestCache.java b/web/src/main/java/org/springframework/security/web/savedrequest/NullRequestCache.java index a1560e53eb..98ecd04795 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/NullRequestCache.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/NullRequestCache.java @@ -8,7 +8,6 @@ import javax.servlet.http.HttpServletResponse; * Typically used when creation of a session is not desired. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class NullRequestCache implements RequestCache { diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/RequestCache.java b/web/src/main/java/org/springframework/security/web/savedrequest/RequestCache.java index eee5f696c9..ec7f033819 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/RequestCache.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/RequestCache.java @@ -8,7 +8,6 @@ import javax.servlet.http.HttpServletResponse; * an authentication mechanism. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface RequestCache { diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/RequestCacheAwareFilter.java b/web/src/main/java/org/springframework/security/web/savedrequest/RequestCacheAwareFilter.java index 6ca1d2cb9a..909208d3c4 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/RequestCacheAwareFilter.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/RequestCacheAwareFilter.java @@ -20,7 +20,6 @@ import org.springframework.web.filter.GenericFilterBean; * If null is returned by the cache, the original request is used and the filter has no effect. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class RequestCacheAwareFilter extends GenericFilterBean { diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/SavedCookie.java b/web/src/main/java/org/springframework/security/web/savedrequest/SavedCookie.java index 514af563ec..6730c6798a 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/SavedCookie.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/SavedCookie.java @@ -1,86 +1,86 @@ -package org.springframework.security.web.savedrequest; - -import javax.servlet.http.Cookie; -import java.io.Serializable; - -/** - * Stores off the values of a cookie in a serializable holder - * - * @author Ray Krueger - */ -public class SavedCookie implements Serializable { - private java.lang.String name; - private java.lang.String value; - private java.lang.String comment; - private java.lang.String domain; - private int maxAge; - private java.lang.String path; - private boolean secure; - private int version; - - public SavedCookie(String name, String value, String comment, String domain, int maxAge, String path, boolean secure, int version) { - this.name = name; - this.value = value; - this.comment = comment; - this.domain = domain; - this.maxAge = maxAge; - this.path = path; - this.secure = secure; - this.version = version; - } - - public SavedCookie(Cookie cookie) { - this(cookie.getName(), cookie.getValue(), cookie.getComment(), - cookie.getDomain(), cookie.getMaxAge(), cookie.getPath(), cookie.getSecure(), cookie.getVersion()); - } - - public String getName() { - return name; - } - - public String getValue() { - return value; - } - - public String getComment() { - return comment; - } - - public String getDomain() { - return domain; - } - - public int getMaxAge() { - return maxAge; - } - - public String getPath() { - return path; - } - - public boolean isSecure() { - return secure; - } - - public int getVersion() { - return version; - } - - public Cookie getCookie() { - Cookie c = new Cookie(getName(), getValue()); - - if (getComment() != null) - c.setComment(getComment()); - - if (getDomain() != null) - c.setDomain(getDomain()); - - if (getPath() != null) - c.setPath(getPath()); - - c.setVersion(getVersion()); - c.setMaxAge(getMaxAge()); - c.setSecure(isSecure()); - return c; - } -} +package org.springframework.security.web.savedrequest; + +import javax.servlet.http.Cookie; +import java.io.Serializable; + +/** + * Stores off the values of a cookie in a serializable holder + * + * @author Ray Krueger + */ +public class SavedCookie implements Serializable { + private java.lang.String name; + private java.lang.String value; + private java.lang.String comment; + private java.lang.String domain; + private int maxAge; + private java.lang.String path; + private boolean secure; + private int version; + + public SavedCookie(String name, String value, String comment, String domain, int maxAge, String path, boolean secure, int version) { + this.name = name; + this.value = value; + this.comment = comment; + this.domain = domain; + this.maxAge = maxAge; + this.path = path; + this.secure = secure; + this.version = version; + } + + public SavedCookie(Cookie cookie) { + this(cookie.getName(), cookie.getValue(), cookie.getComment(), + cookie.getDomain(), cookie.getMaxAge(), cookie.getPath(), cookie.getSecure(), cookie.getVersion()); + } + + public String getName() { + return name; + } + + public String getValue() { + return value; + } + + public String getComment() { + return comment; + } + + public String getDomain() { + return domain; + } + + public int getMaxAge() { + return maxAge; + } + + public String getPath() { + return path; + } + + public boolean isSecure() { + return secure; + } + + public int getVersion() { + return version; + } + + public Cookie getCookie() { + Cookie c = new Cookie(getName(), getValue()); + + if (getComment() != null) + c.setComment(getComment()); + + if (getDomain() != null) + c.setDomain(getDomain()); + + if (getPath() != null) + c.setPath(getPath()); + + c.setVersion(getVersion()); + c.setMaxAge(getMaxAge()); + c.setSecure(isSecure()); + return c; + } +} diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/SavedRequest.java b/web/src/main/java/org/springframework/security/web/savedrequest/SavedRequest.java index 9d1307db59..491642cfa4 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/SavedRequest.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/SavedRequest.java @@ -13,7 +13,6 @@ import javax.servlet.http.Cookie; * reproducing the original request data. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public interface SavedRequest extends java.io.Serializable { diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/SavedRequestAwareWrapper.java b/web/src/main/java/org/springframework/security/web/savedrequest/SavedRequestAwareWrapper.java index 3e5c452118..180f766dc6 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/SavedRequestAwareWrapper.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/SavedRequestAwareWrapper.java @@ -48,7 +48,6 @@ import org.apache.commons.logging.LogFactory; * @author Andrey Grebnev * @author Ben Alex * @author Luke Taylor - * @version $Id$ */ class SavedRequestAwareWrapper extends HttpServletRequestWrapper { //~ Static fields/initializers ===================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/package.html b/web/src/main/java/org/springframework/security/web/savedrequest/package.html index 4eb5c52d65..3a00f47fc5 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/package.html +++ b/web/src/main/java/org/springframework/security/web/savedrequest/package.html @@ -1,8 +1,8 @@ - - -Classes related top the caching of an HttpServletRequest which requires authentication. While the user is -logging in, the request is cached (using the RequestCache implementation) by the ExceptionTranslationFilter. -Once the user has been authenticated, the original request is restored following a redirect to a matching URL, and the -RequestCache is queried to obtain the original (matching) request. - - + + +Classes related top the caching of an HttpServletRequest which requires authentication. While the user is +logging in, the request is cached (using the RequestCache implementation) by the ExceptionTranslationFilter. +Once the user has been authenticated, the original request is restored following a redirect to a matching URL, and the +RequestCache is queried to obtain the original (matching) request. + + diff --git a/web/src/main/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilter.java b/web/src/main/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilter.java index 298bebb97a..0b9937ae26 100644 --- a/web/src/main/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilter.java +++ b/web/src/main/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilter.java @@ -36,7 +36,6 @@ import org.springframework.web.filter.GenericFilterBean; * @author Orlando Garcia Carmona * @author Ben Alex * @author Luke Taylor - * @version $Id$ */ public class SecurityContextHolderAwareRequestFilter extends GenericFilterBean { //~ Instance fields ================================================================================================ diff --git a/web/src/main/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestWrapper.java b/web/src/main/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestWrapper.java index c9fbc1137e..baf4276fc1 100644 --- a/web/src/main/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestWrapper.java +++ b/web/src/main/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestWrapper.java @@ -41,7 +41,6 @@ import org.springframework.security.core.userdetails.UserDetails; * @author Orlando Garcia Carmona * @author Ben Alex * @author Luke Taylor - * @version $Id$ */ public class SecurityContextHolderAwareRequestWrapper extends HttpServletRequestWrapper { //~ Instance fields ================================================================================================ diff --git a/web/src/main/java/org/springframework/security/web/session/HttpSessionEventPublisher.java b/web/src/main/java/org/springframework/security/web/session/HttpSessionEventPublisher.java index 853ed46c02..643043c342 100644 --- a/web/src/main/java/org/springframework/security/web/session/HttpSessionEventPublisher.java +++ b/web/src/main/java/org/springframework/security/web/session/HttpSessionEventPublisher.java @@ -40,7 +40,6 @@ import javax.servlet.http.HttpSessionListener; * javax.servlet.http.HttpSessionListener.sessionDestroyed() to {@link HttpSessionDestroyedEvent}. * * @author Ray Krueger - * @version $Id$ */ public class HttpSessionEventPublisher implements HttpSessionListener { //~ Static fields/initializers ===================================================================================== diff --git a/web/src/main/java/org/springframework/security/web/util/AntUrlPathMatcher.java b/web/src/main/java/org/springframework/security/web/util/AntUrlPathMatcher.java index 0cdb9ebf8d..f0fbadf0b1 100644 --- a/web/src/main/java/org/springframework/security/web/util/AntUrlPathMatcher.java +++ b/web/src/main/java/org/springframework/security/web/util/AntUrlPathMatcher.java @@ -7,7 +7,6 @@ import org.springframework.util.AntPathMatcher; * Ant path strategy for URL matching. * * @author Luke Taylor - * @version $Id$ */ public class AntUrlPathMatcher implements UrlMatcher { private boolean requiresLowerCaseUrl = true; @@ -47,5 +46,5 @@ public class AntUrlPathMatcher implements UrlMatcher { public String toString() { return getClass().getName() + "[requiresLowerCase='" + requiresLowerCaseUrl + "']"; - } + } } diff --git a/web/src/main/java/org/springframework/security/web/util/RedirectUrlBuilder.java b/web/src/main/java/org/springframework/security/web/util/RedirectUrlBuilder.java index cc723fb0e5..8ce448a4e0 100644 --- a/web/src/main/java/org/springframework/security/web/util/RedirectUrlBuilder.java +++ b/web/src/main/java/org/springframework/security/web/util/RedirectUrlBuilder.java @@ -8,7 +8,6 @@ import org.springframework.util.Assert; * Could probably make more use of the classes in java.net for this. * * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public class RedirectUrlBuilder { @@ -79,7 +78,7 @@ public class RedirectUrlBuilder { if (query != null) { sb.append("?").append(query); } - + return sb.toString(); } } diff --git a/web/src/main/java/org/springframework/security/web/util/RegexUrlPathMatcher.java b/web/src/main/java/org/springframework/security/web/util/RegexUrlPathMatcher.java index 6fcb020be0..5445d074c5 100644 --- a/web/src/main/java/org/springframework/security/web/util/RegexUrlPathMatcher.java +++ b/web/src/main/java/org/springframework/security/web/util/RegexUrlPathMatcher.java @@ -4,7 +4,6 @@ import java.util.regex.Pattern; /** * @author Luke Taylor - * @version $Id$ */ public class RegexUrlPathMatcher implements UrlMatcher { private boolean requiresLowerCaseUrl = false; diff --git a/web/src/main/java/org/springframework/security/web/util/TextEscapeUtils.java b/web/src/main/java/org/springframework/security/web/util/TextEscapeUtils.java index 289d2c734f..bbbe1dbc41 100644 --- a/web/src/main/java/org/springframework/security/web/util/TextEscapeUtils.java +++ b/web/src/main/java/org/springframework/security/web/util/TextEscapeUtils.java @@ -4,7 +4,6 @@ package org.springframework.security.web.util; * Utility for escaping characters in HTML strings. * * @author Luke Taylor - * @version $Id$ */ public abstract class TextEscapeUtils { diff --git a/web/src/main/java/org/springframework/security/web/util/ThrowableAnalyzer.java b/web/src/main/java/org/springframework/security/web/util/ThrowableAnalyzer.java index 0781dc55f1..f201d29741 100755 --- a/web/src/main/java/org/springframework/security/web/util/ThrowableAnalyzer.java +++ b/web/src/main/java/org/springframework/security/web/util/ThrowableAnalyzer.java @@ -17,7 +17,6 @@ import org.springframework.util.Assert; * * @author Andreas Senft * @since 2.0 - * @version $Id$ */ public class ThrowableAnalyzer { diff --git a/web/src/main/java/org/springframework/security/web/util/ThrowableCauseExtractor.java b/web/src/main/java/org/springframework/security/web/util/ThrowableCauseExtractor.java index 8e68ed8d65..7526d84139 100755 --- a/web/src/main/java/org/springframework/security/web/util/ThrowableCauseExtractor.java +++ b/web/src/main/java/org/springframework/security/web/util/ThrowableCauseExtractor.java @@ -3,22 +3,21 @@ package org.springframework.security.web.util; /** * Interface for handlers extracting the cause out of a specific {@link Throwable} type. - * + * * @author Andreas Senft * @since 2.0 - * @version $Id$ - * + * * @see ThrowableAnalyzer */ public interface ThrowableCauseExtractor { /** * Extracts the cause from the provided Throwable. - * + * * @param throwable the Throwable * @return the extracted cause (maybe null) - * - * @throws IllegalArgumentException if throwable is null + * + * @throws IllegalArgumentException if throwable is null * or otherwise considered invalid for the implementation */ Throwable extractCause(Throwable throwable); diff --git a/web/src/main/java/org/springframework/security/web/util/UrlMatcher.java b/web/src/main/java/org/springframework/security/web/util/UrlMatcher.java index be93039667..5367267190 100644 --- a/web/src/main/java/org/springframework/security/web/util/UrlMatcher.java +++ b/web/src/main/java/org/springframework/security/web/util/UrlMatcher.java @@ -4,7 +4,6 @@ package org.springframework.security.web.util; * Strategy for deciding whether configured path matches a submitted candidate URL. * * @author Luke Taylor - * @version $Id$ * @since 2.0 */ public interface UrlMatcher { diff --git a/web/src/main/java/org/springframework/security/web/util/UrlUtils.java b/web/src/main/java/org/springframework/security/web/util/UrlUtils.java index ff2a4f27f5..25695e6fb5 100644 --- a/web/src/main/java/org/springframework/security/web/util/UrlUtils.java +++ b/web/src/main/java/org/springframework/security/web/util/UrlUtils.java @@ -1,124 +1,124 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.web.util; - -import javax.servlet.http.HttpServletRequest; - - -/** - * Provides static methods for composing URLs.

    Placed into a separate class for visibility, so that changes to - * URL formatting conventions will affect all users.

    - * - * @author Ben Alex - */ -public final class UrlUtils { - //~ Methods ======================================================================================================== - - public static String buildFullRequestUrl(HttpServletRequest r) { - return buildFullRequestUrl(r.getScheme(), r.getServerName(), r.getServerPort(), r.getRequestURI(), - r.getQueryString()); - } - - /** - * Obtains the full URL the client used to make the request. - *

    - * Note that the server port will not be shown if it is the default server port for HTTP or HTTPS - * (80 and 443 respectively). - * - * @return the full URL, suitable for redirects (not decoded). - */ - public static String buildFullRequestUrl(String scheme, String serverName, int serverPort, String requestURI, - String queryString) { - - scheme = scheme.toLowerCase(); - - StringBuilder url = new StringBuilder(); - url.append(scheme).append("://").append(serverName); - - // Only add port if not default - if ("http".equals(scheme)) { - if (serverPort != 80) { - url.append(":").append(serverPort); - } - } else if ("https".equals(scheme)) { - if (serverPort != 443) { - url.append(":").append(serverPort); - } - } - - // Use the requestURI as it is encoded (RFC 3986) and hence suitable for redirects. - url.append(requestURI); - - if (queryString != null) { - url.append("?").append(queryString); - } - - return url.toString(); - } - - /** - * Obtains the web application-specific fragment of the request URL. - *

    - * Under normal spec conditions, - *

    -     * requestURI = contextPath + servletPath + pathInfo
    -     * 
    - * - * But the requestURI is not decoded, whereas the servletPath and pathInfo are (SEC-1255). - * This method is typically used to return a URL for matching against secured paths, hence the decoded form is - * used in preference to the requestURI for building the returned value. But this method may also be called using - * dummy request objects which just have the requestURI and contextPatth set, for example, so it will fall back to - * using those. - * - * @return the decoded URL, excluding any server name, context path or servlet path - * - */ - public static String buildRequestUrl(HttpServletRequest r) { - return buildRequestUrl(r.getServletPath(), r.getRequestURI(), r.getContextPath(), r.getPathInfo(), - r.getQueryString()); - } - - /** - * Obtains the web application-specific fragment of the URL. - */ - private static String buildRequestUrl(String servletPath, String requestURI, String contextPath, String pathInfo, - String queryString) { - - StringBuilder url = new StringBuilder(); - - if (servletPath != null) { - url.append(servletPath); - if (pathInfo != null) { - url.append(pathInfo); - } - } else { - url.append(requestURI.substring(contextPath.length())); - } - - if (queryString != null) { - url.append("?").append(queryString); - } - - return url.toString(); - } - - /** - * Returns true if the supplied URL starts with a "/" or "http". - */ - public static boolean isValidRedirectUrl(String url) { - return url != null && url.startsWith("/") || url.toLowerCase().startsWith("http"); - } -} +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.web.util; + +import javax.servlet.http.HttpServletRequest; + + +/** + * Provides static methods for composing URLs.

    Placed into a separate class for visibility, so that changes to + * URL formatting conventions will affect all users.

    + * + * @author Ben Alex + */ +public final class UrlUtils { + //~ Methods ======================================================================================================== + + public static String buildFullRequestUrl(HttpServletRequest r) { + return buildFullRequestUrl(r.getScheme(), r.getServerName(), r.getServerPort(), r.getRequestURI(), + r.getQueryString()); + } + + /** + * Obtains the full URL the client used to make the request. + *

    + * Note that the server port will not be shown if it is the default server port for HTTP or HTTPS + * (80 and 443 respectively). + * + * @return the full URL, suitable for redirects (not decoded). + */ + public static String buildFullRequestUrl(String scheme, String serverName, int serverPort, String requestURI, + String queryString) { + + scheme = scheme.toLowerCase(); + + StringBuilder url = new StringBuilder(); + url.append(scheme).append("://").append(serverName); + + // Only add port if not default + if ("http".equals(scheme)) { + if (serverPort != 80) { + url.append(":").append(serverPort); + } + } else if ("https".equals(scheme)) { + if (serverPort != 443) { + url.append(":").append(serverPort); + } + } + + // Use the requestURI as it is encoded (RFC 3986) and hence suitable for redirects. + url.append(requestURI); + + if (queryString != null) { + url.append("?").append(queryString); + } + + return url.toString(); + } + + /** + * Obtains the web application-specific fragment of the request URL. + *

    + * Under normal spec conditions, + *

    +     * requestURI = contextPath + servletPath + pathInfo
    +     * 
    + * + * But the requestURI is not decoded, whereas the servletPath and pathInfo are (SEC-1255). + * This method is typically used to return a URL for matching against secured paths, hence the decoded form is + * used in preference to the requestURI for building the returned value. But this method may also be called using + * dummy request objects which just have the requestURI and contextPatth set, for example, so it will fall back to + * using those. + * + * @return the decoded URL, excluding any server name, context path or servlet path + * + */ + public static String buildRequestUrl(HttpServletRequest r) { + return buildRequestUrl(r.getServletPath(), r.getRequestURI(), r.getContextPath(), r.getPathInfo(), + r.getQueryString()); + } + + /** + * Obtains the web application-specific fragment of the URL. + */ + private static String buildRequestUrl(String servletPath, String requestURI, String contextPath, String pathInfo, + String queryString) { + + StringBuilder url = new StringBuilder(); + + if (servletPath != null) { + url.append(servletPath); + if (pathInfo != null) { + url.append(pathInfo); + } + } else { + url.append(requestURI.substring(contextPath.length())); + } + + if (queryString != null) { + url.append("?").append(queryString); + } + + return url.toString(); + } + + /** + * Returns true if the supplied URL starts with a "/" or "http". + */ + public static boolean isValidRedirectUrl(String url) { + return url != null && url.startsWith("/") || url.toLowerCase().startsWith("http"); + } +} diff --git a/web/src/test/java/org/springframework/security/MockFilterConfig.java b/web/src/test/java/org/springframework/security/MockFilterConfig.java index fb24e3c71c..0b79951107 100644 --- a/web/src/test/java/org/springframework/security/MockFilterConfig.java +++ b/web/src/test/java/org/springframework/security/MockFilterConfig.java @@ -26,7 +26,6 @@ import javax.servlet.ServletContext; /** * * @author Ben Alex - * @version $Id$ */ @SuppressWarnings("unchecked") public class MockFilterConfig implements FilterConfig { diff --git a/web/src/test/java/org/springframework/security/MockPortResolver.java b/web/src/test/java/org/springframework/security/MockPortResolver.java index b64017e93a..c90b2b1ef8 100644 --- a/web/src/test/java/org/springframework/security/MockPortResolver.java +++ b/web/src/test/java/org/springframework/security/MockPortResolver.java @@ -24,7 +24,6 @@ import javax.servlet.ServletRequest; * Always returns the constructor-specified HTTP and HTTPS ports. * * @author Ben Alex - * @version $Id$ */ public class MockPortResolver implements PortResolver { //~ Instance fields ================================================================================================ diff --git a/web/src/test/java/org/springframework/security/web/PortMapperImplTests.java b/web/src/test/java/org/springframework/security/web/PortMapperImplTests.java index 6f66744266..3b75c4aa4f 100644 --- a/web/src/test/java/org/springframework/security/web/PortMapperImplTests.java +++ b/web/src/test/java/org/springframework/security/web/PortMapperImplTests.java @@ -27,7 +27,6 @@ import org.springframework.security.web.PortMapperImpl; * Tests {@link PortMapperImpl}. * * @author Ben Alex - * @version $Id$ */ public class PortMapperImplTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/PortResolverImplTests.java b/web/src/test/java/org/springframework/security/web/PortResolverImplTests.java index b91fe33cf5..008a958657 100644 --- a/web/src/test/java/org/springframework/security/web/PortResolverImplTests.java +++ b/web/src/test/java/org/springframework/security/web/PortResolverImplTests.java @@ -26,7 +26,6 @@ import org.springframework.security.web.PortResolverImpl; * Tests {@link PortResolverImpl}. * * @author Ben Alex - * @version $Id$ */ public class PortResolverImplTests extends TestCase { //~ Constructors =================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluatorTests.java b/web/src/test/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluatorTests.java index 1d91007fc1..283154604e 100644 --- a/web/src/test/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluatorTests.java +++ b/web/src/test/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluatorTests.java @@ -41,7 +41,6 @@ import org.springframework.security.web.util.UrlUtils; * Tests {@link org.springframework.security.web.access.DefaultWebInvocationPrivilegeEvaluator}. * * @author Ben Alex - * @version $Id$ */ public class DefaultWebInvocationPrivilegeEvaluatorTests { private AccessDecisionManager adm; diff --git a/web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java b/web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java index 8828eb90a4..f7b75b8af6 100644 --- a/web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java @@ -49,7 +49,6 @@ import org.springframework.security.web.util.ThrowableAnalyzer; * Tests {@link ExceptionTranslationFilter}. * * @author Ben Alex - * @version $Id$ */ public class ExceptionTranslationFilterTests { diff --git a/web/src/test/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImplTests.java b/web/src/test/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImplTests.java index 8eadd338c3..20ee3ff87b 100644 --- a/web/src/test/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImplTests.java +++ b/web/src/test/java/org/springframework/security/web/access/channel/ChannelDecisionManagerImplTests.java @@ -41,7 +41,6 @@ import org.springframework.security.web.access.channel.ChannelProcessor; * Tests {@link ChannelDecisionManagerImpl}. * * @author Ben Alex - * @version $Id$ */ @SuppressWarnings("unchecked") public class ChannelDecisionManagerImplTests extends TestCase { diff --git a/web/src/test/java/org/springframework/security/web/access/channel/ChannelProcessingFilterTests.java b/web/src/test/java/org/springframework/security/web/access/channel/ChannelProcessingFilterTests.java index 8a122bdcfb..5fd81f20ef 100644 --- a/web/src/test/java/org/springframework/security/web/access/channel/ChannelProcessingFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/access/channel/ChannelProcessingFilterTests.java @@ -37,7 +37,6 @@ import org.springframework.security.web.access.intercept.FilterInvocationSecurit * Tests {@link ChannelProcessingFilter}. * * @author Ben Alex - * @version $Id$ */ public class ChannelProcessingFilterTests { //~ Methods ======================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/access/channel/InsecureChannelProcessorTests.java b/web/src/test/java/org/springframework/security/web/access/channel/InsecureChannelProcessorTests.java index 0245026f37..773626103f 100644 --- a/web/src/test/java/org/springframework/security/web/access/channel/InsecureChannelProcessorTests.java +++ b/web/src/test/java/org/springframework/security/web/access/channel/InsecureChannelProcessorTests.java @@ -32,7 +32,6 @@ import org.springframework.security.web.access.channel.InsecureChannelProcessor; * Tests {@link InsecureChannelProcessor}. * * @author Ben Alex - * @version $Id$ */ public class InsecureChannelProcessorTests extends TestCase { diff --git a/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpEntryPointTests.java b/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpEntryPointTests.java index 5c6df52a59..c7eb3b713f 100644 --- a/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpEntryPointTests.java +++ b/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpEntryPointTests.java @@ -33,7 +33,6 @@ import java.util.Map; * Tests {@link RetryWithHttpEntryPoint}. * * @author Ben Alex - * @version $Id$ */ public class RetryWithHttpEntryPointTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpsEntryPointTests.java b/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpsEntryPointTests.java index 0618d67721..b3024bb530 100644 --- a/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpsEntryPointTests.java +++ b/web/src/test/java/org/springframework/security/web/access/channel/RetryWithHttpsEntryPointTests.java @@ -33,7 +33,6 @@ import java.util.Map; * Tests {@link RetryWithHttpsEntryPoint}. * * @author Ben Alex - * @version $Id$ */ public class RetryWithHttpsEntryPointTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/access/channel/SecureChannelProcessorTests.java b/web/src/test/java/org/springframework/security/web/access/channel/SecureChannelProcessorTests.java index 49791cb665..8f20c8869a 100644 --- a/web/src/test/java/org/springframework/security/web/access/channel/SecureChannelProcessorTests.java +++ b/web/src/test/java/org/springframework/security/web/access/channel/SecureChannelProcessorTests.java @@ -32,7 +32,6 @@ import org.springframework.security.web.access.channel.SecureChannelProcessor; * Tests {@link SecureChannelProcessor}. * * @author Ben Alex - * @version $Id$ */ public class SecureChannelProcessorTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/access/expression/WebSecurityExpressionRootTests.java b/web/src/test/java/org/springframework/security/web/access/expression/WebSecurityExpressionRootTests.java index 2e23167c83..bad31dea01 100644 --- a/web/src/test/java/org/springframework/security/web/access/expression/WebSecurityExpressionRootTests.java +++ b/web/src/test/java/org/springframework/security/web/access/expression/WebSecurityExpressionRootTests.java @@ -16,7 +16,6 @@ import org.springframework.security.web.access.expression.WebSecurityExpressionR * Tests for {@link WebSecurityExpressionRoot}. * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class WebSecurityExpressionRootTests { diff --git a/web/src/test/java/org/springframework/security/web/access/intercept/DefaultFilterInvocationSecurityMetadataSourceTests.java b/web/src/test/java/org/springframework/security/web/access/intercept/DefaultFilterInvocationSecurityMetadataSourceTests.java index 329f8854b4..9fce8600df 100644 --- a/web/src/test/java/org/springframework/security/web/access/intercept/DefaultFilterInvocationSecurityMetadataSourceTests.java +++ b/web/src/test/java/org/springframework/security/web/access/intercept/DefaultFilterInvocationSecurityMetadataSourceTests.java @@ -38,7 +38,6 @@ import org.springframework.security.web.util.AntUrlPathMatcher; * FilterInvocationDefinitionSourceEditorTests}. * * @author Ben Alex - * @version $Id$ */ @SuppressWarnings("unchecked") public class DefaultFilterInvocationSecurityMetadataSourceTests { diff --git a/web/src/test/java/org/springframework/security/web/access/intercept/FilterInvocationTests.java b/web/src/test/java/org/springframework/security/web/access/intercept/FilterInvocationTests.java index 1d64a66fd2..8fd098ce7d 100644 --- a/web/src/test/java/org/springframework/security/web/access/intercept/FilterInvocationTests.java +++ b/web/src/test/java/org/springframework/security/web/access/intercept/FilterInvocationTests.java @@ -30,7 +30,6 @@ import org.springframework.security.web.FilterInvocation; * * @author Ben Alex * @author colin sampaleanu - * @version $Id$ */ public class FilterInvocationTests { diff --git a/web/src/test/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptorTests.java b/web/src/test/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptorTests.java index 2e7261c877..c3187a0439 100644 --- a/web/src/test/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptorTests.java +++ b/web/src/test/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptorTests.java @@ -46,7 +46,6 @@ import org.springframework.security.web.access.intercept.FilterSecurityIntercept * Tests {@link FilterSecurityInterceptor}. * * @author Ben Alex - * @version $Id$ */ public class FilterSecurityInterceptorTests { private Mockery jmock = new JUnit4Mockery(); diff --git a/web/src/test/java/org/springframework/security/web/access/intercept/RequestKeyTests.java b/web/src/test/java/org/springframework/security/web/access/intercept/RequestKeyTests.java index ddf3aeec9a..9c5a482225 100644 --- a/web/src/test/java/org/springframework/security/web/access/intercept/RequestKeyTests.java +++ b/web/src/test/java/org/springframework/security/web/access/intercept/RequestKeyTests.java @@ -6,18 +6,17 @@ import org.junit.Test; import org.springframework.security.web.access.intercept.RequestKey; /** - * + * * @author Luke Taylor - * @version $Id$ * */ public class RequestKeyTests { - + @Test public void equalsWorksWithNullHttpMethod() { RequestKey key1 = new RequestKey("/someurl"); RequestKey key2 = new RequestKey("/someurl"); - + assertEquals(key1, key2); key1 = new RequestKey("/someurl","GET"); assertFalse(key1.equals(key2)); @@ -28,7 +27,7 @@ public class RequestKeyTests { public void keysWithSameUrlAndHttpMethodAreEqual() { RequestKey key1 = new RequestKey("/someurl", "GET"); RequestKey key2 = new RequestKey("/someurl", "GET"); - + assertEquals(key1, key2); } @@ -36,7 +35,7 @@ public class RequestKeyTests { public void keysWithSameUrlAndDifferentHttpMethodAreNotEqual() { RequestKey key1 = new RequestKey("/someurl", "GET"); RequestKey key2 = new RequestKey("/someurl", "POST"); - + assertFalse(key1.equals(key2)); assertFalse(key2.equals(key1)); } @@ -45,7 +44,7 @@ public class RequestKeyTests { public void keysWithDifferentUrlsAreNotEquals() { RequestKey key1 = new RequestKey("/someurl", "GET"); RequestKey key2 = new RequestKey("/anotherurl", "GET"); - + assertFalse(key1.equals(key2)); assertFalse(key2.equals(key1)); } diff --git a/web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilterTests.java index 7b7a30240b..7199afc7f7 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilterTests.java @@ -57,7 +57,6 @@ import org.springframework.security.web.savedrequest.DefaultSavedRequest; * Tests {@link AbstractAuthenticationProcessingFilter}. * * @author Ben Alex - * @version $Id$ */ public class AbstractAuthenticationProcessingFilterTests extends TestCase { SavedRequestAwareAuthenticationSuccessHandler successHandler; diff --git a/web/src/test/java/org/springframework/security/web/authentication/AnonymousAuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/AnonymousAuthenticationFilterTests.java index bdaffa0bf4..0ca3f9302e 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/AnonymousAuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/AnonymousAuthenticationFilterTests.java @@ -45,7 +45,6 @@ import org.springframework.security.core.userdetails.memory.UserAttribute; * Tests {@link AnonymousAuthenticationFilter}. * * @author Ben Alex - * @version $Id$ */ public class AnonymousAuthenticationFilterTests { diff --git a/web/src/test/java/org/springframework/security/web/authentication/DefaultLoginPageGeneratingFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/DefaultLoginPageGeneratingFilterTests.java index 33f125ee39..f3ae234a32 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/DefaultLoginPageGeneratingFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/DefaultLoginPageGeneratingFilterTests.java @@ -21,7 +21,6 @@ import org.springframework.security.web.authentication.ui.DefaultLoginPageGenera /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class DefaultLoginPageGeneratingFilterTests { diff --git a/web/src/test/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPointTests.java b/web/src/test/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPointTests.java index 6e3da2eb02..1ca323587a 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPointTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPointTests.java @@ -34,7 +34,6 @@ import java.util.Map; * * @author Ben Alex * @author colin sampaleanu - * @version $Id$ */ public class LoginUrlAuthenticationEntryPointTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilterTests.java index b05497819e..207ca01223 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilterTests.java @@ -38,7 +38,6 @@ import org.springframework.security.core.AuthenticationException; * Tests {@link UsernamePasswordAuthenticationFilter}. * * @author Ben Alex - * @version $Id$ */ public class UsernamePasswordAuthenticationFilterTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/authentication/logout/LogoutHandlerTests.java b/web/src/test/java/org/springframework/security/web/authentication/logout/LogoutHandlerTests.java index ac359b59d8..10f9abd92f 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/logout/LogoutHandlerTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/logout/LogoutHandlerTests.java @@ -9,7 +9,6 @@ import org.springframework.security.web.authentication.logout.SecurityContextLog /** * @author Luke Taylor - * @version $Id$ */ public class LogoutHandlerTests extends TestCase { LogoutFilter filter; diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/Http403ForbiddenEntryPointTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/Http403ForbiddenEntryPointTests.java index f5e07403cf..17edd579e5 100755 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/Http403ForbiddenEntryPointTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/Http403ForbiddenEntryPointTests.java @@ -1,31 +1,31 @@ -package org.springframework.security.web.authentication.preauth; - -import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException; -import org.springframework.security.web.authentication.Http403ForbiddenEntryPoint; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletResponse; - -import junit.framework.TestCase; - -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; - -public class Http403ForbiddenEntryPointTests extends TestCase { - - public void testCommence() { - MockHttpServletRequest req = new MockHttpServletRequest(); - MockHttpServletResponse resp = new MockHttpServletResponse(); - Http403ForbiddenEntryPoint fep = new Http403ForbiddenEntryPoint(); - try { - fep.commence(req,resp,new AuthenticationCredentialsNotFoundException("test")); - assertEquals("Incorrect status",resp.getStatus(),HttpServletResponse.SC_FORBIDDEN); - } catch (IOException e) { - fail("Unexpected exception thrown: "+e); - } catch (ServletException e) { - fail("Unexpected exception thrown: "+e); - } - } -} +package org.springframework.security.web.authentication.preauth; + +import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException; +import org.springframework.security.web.authentication.Http403ForbiddenEntryPoint; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletResponse; + +import junit.framework.TestCase; + +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; + +public class Http403ForbiddenEntryPointTests extends TestCase { + + public void testCommence() { + MockHttpServletRequest req = new MockHttpServletRequest(); + MockHttpServletResponse resp = new MockHttpServletResponse(); + Http403ForbiddenEntryPoint fep = new Http403ForbiddenEntryPoint(); + try { + fep.commence(req,resp,new AuthenticationCredentialsNotFoundException("test")); + assertEquals("Incorrect status",resp.getStatus(),HttpServletResponse.SC_FORBIDDEN); + } catch (IOException e) { + fail("Unexpected exception thrown: "+e); + } catch (ServletException e) { + fail("Unexpected exception thrown: "+e); + } + } +} diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProviderTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProviderTests.java index 7938ca0e35..6843acf778 100755 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProviderTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProviderTests.java @@ -1,119 +1,119 @@ -package org.springframework.security.web.authentication.preauth; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider; -import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; - -/** - * - * @author TSARDD - * @since 18-okt-2007 - */ -public class PreAuthenticatedAuthenticationProviderTests { - - @Test(expected = IllegalArgumentException.class) - public final void afterPropertiesSet() { - PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider(); - - provider.afterPropertiesSet(); - } - - @Test - public final void authenticateInvalidToken() throws Exception { - UserDetails ud = new User("dummyUser", "dummyPwd", true, true, true, true, AuthorityUtils.NO_AUTHORITIES ); - PreAuthenticatedAuthenticationProvider provider = getProvider(ud); - Authentication request = new UsernamePasswordAuthenticationToken("dummyUser", "dummyPwd"); - Authentication result = provider.authenticate(request); - assertNull(result); - } - - @Test - public final void nullPrincipalReturnsNullAuthentication() throws Exception { - PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider(); - Authentication request = new PreAuthenticatedAuthenticationToken(null, "dummyPwd"); - Authentication result = provider.authenticate(request); - assertNull(result); - } - - @Test - public final void authenticateKnownUser() throws Exception { - UserDetails ud = new User("dummyUser", "dummyPwd", true, true, true, true, AuthorityUtils.NO_AUTHORITIES ); - PreAuthenticatedAuthenticationProvider provider = getProvider(ud); - Authentication request = new PreAuthenticatedAuthenticationToken("dummyUser", "dummyPwd"); - Authentication result = provider.authenticate(request); - assertNotNull(result); - assertEquals(result.getPrincipal(), ud); - // @TODO: Add more asserts? - } - - @Test - public final void authenticateIgnoreCredentials() throws Exception { - UserDetails ud = new User("dummyUser1", "dummyPwd1", true, true, true, true, AuthorityUtils.NO_AUTHORITIES ); - PreAuthenticatedAuthenticationProvider provider = getProvider(ud); - Authentication request = new PreAuthenticatedAuthenticationToken("dummyUser1", "dummyPwd2"); - Authentication result = provider.authenticate(request); - assertNotNull(result); - assertEquals(result.getPrincipal(), ud); - // @TODO: Add more asserts? - } - - @Test(expected=UsernameNotFoundException.class) - public final void authenticateUnknownUserThrowsException() throws Exception { - UserDetails ud = new User("dummyUser1", "dummyPwd", true, true, true, true, AuthorityUtils.NO_AUTHORITIES ); - PreAuthenticatedAuthenticationProvider provider = getProvider(ud); - Authentication request = new PreAuthenticatedAuthenticationToken("dummyUser2", "dummyPwd"); - provider.authenticate(request); - } - - @Test - public final void supportsArbitraryObject() throws Exception { - PreAuthenticatedAuthenticationProvider provider = getProvider(null); - assertFalse(provider.supports(Authentication.class)); - } - - @Test - public final void supportsPreAuthenticatedAuthenticationToken() throws Exception { - PreAuthenticatedAuthenticationProvider provider = getProvider(null); - assertTrue(provider.supports(PreAuthenticatedAuthenticationToken.class)); - } - - @Test - public void getSetOrder() throws Exception { - PreAuthenticatedAuthenticationProvider provider = getProvider(null); - provider.setOrder(333); - assertEquals(provider.getOrder(), 333); - } - - private PreAuthenticatedAuthenticationProvider getProvider(UserDetails aUserDetails) throws Exception { - PreAuthenticatedAuthenticationProvider result = new PreAuthenticatedAuthenticationProvider(); - result.setPreAuthenticatedUserDetailsService(getPreAuthenticatedUserDetailsService(aUserDetails)); - result.afterPropertiesSet(); - return result; - } - - private AuthenticationUserDetailsService getPreAuthenticatedUserDetailsService(final UserDetails aUserDetails) { - return new AuthenticationUserDetailsService() { - public UserDetails loadUserDetails(Authentication token) throws UsernameNotFoundException { - if (aUserDetails != null && aUserDetails.getUsername().equals(token.getName())) { - return aUserDetails; - } - - throw new UsernameNotFoundException("notfound"); - } - }; - } - -} +package org.springframework.security.web.authentication.preauth; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider; +import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; + +/** + * + * @author TSARDD + * @since 18-okt-2007 + */ +public class PreAuthenticatedAuthenticationProviderTests { + + @Test(expected = IllegalArgumentException.class) + public final void afterPropertiesSet() { + PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider(); + + provider.afterPropertiesSet(); + } + + @Test + public final void authenticateInvalidToken() throws Exception { + UserDetails ud = new User("dummyUser", "dummyPwd", true, true, true, true, AuthorityUtils.NO_AUTHORITIES ); + PreAuthenticatedAuthenticationProvider provider = getProvider(ud); + Authentication request = new UsernamePasswordAuthenticationToken("dummyUser", "dummyPwd"); + Authentication result = provider.authenticate(request); + assertNull(result); + } + + @Test + public final void nullPrincipalReturnsNullAuthentication() throws Exception { + PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider(); + Authentication request = new PreAuthenticatedAuthenticationToken(null, "dummyPwd"); + Authentication result = provider.authenticate(request); + assertNull(result); + } + + @Test + public final void authenticateKnownUser() throws Exception { + UserDetails ud = new User("dummyUser", "dummyPwd", true, true, true, true, AuthorityUtils.NO_AUTHORITIES ); + PreAuthenticatedAuthenticationProvider provider = getProvider(ud); + Authentication request = new PreAuthenticatedAuthenticationToken("dummyUser", "dummyPwd"); + Authentication result = provider.authenticate(request); + assertNotNull(result); + assertEquals(result.getPrincipal(), ud); + // @TODO: Add more asserts? + } + + @Test + public final void authenticateIgnoreCredentials() throws Exception { + UserDetails ud = new User("dummyUser1", "dummyPwd1", true, true, true, true, AuthorityUtils.NO_AUTHORITIES ); + PreAuthenticatedAuthenticationProvider provider = getProvider(ud); + Authentication request = new PreAuthenticatedAuthenticationToken("dummyUser1", "dummyPwd2"); + Authentication result = provider.authenticate(request); + assertNotNull(result); + assertEquals(result.getPrincipal(), ud); + // @TODO: Add more asserts? + } + + @Test(expected=UsernameNotFoundException.class) + public final void authenticateUnknownUserThrowsException() throws Exception { + UserDetails ud = new User("dummyUser1", "dummyPwd", true, true, true, true, AuthorityUtils.NO_AUTHORITIES ); + PreAuthenticatedAuthenticationProvider provider = getProvider(ud); + Authentication request = new PreAuthenticatedAuthenticationToken("dummyUser2", "dummyPwd"); + provider.authenticate(request); + } + + @Test + public final void supportsArbitraryObject() throws Exception { + PreAuthenticatedAuthenticationProvider provider = getProvider(null); + assertFalse(provider.supports(Authentication.class)); + } + + @Test + public final void supportsPreAuthenticatedAuthenticationToken() throws Exception { + PreAuthenticatedAuthenticationProvider provider = getProvider(null); + assertTrue(provider.supports(PreAuthenticatedAuthenticationToken.class)); + } + + @Test + public void getSetOrder() throws Exception { + PreAuthenticatedAuthenticationProvider provider = getProvider(null); + provider.setOrder(333); + assertEquals(provider.getOrder(), 333); + } + + private PreAuthenticatedAuthenticationProvider getProvider(UserDetails aUserDetails) throws Exception { + PreAuthenticatedAuthenticationProvider result = new PreAuthenticatedAuthenticationProvider(); + result.setPreAuthenticatedUserDetailsService(getPreAuthenticatedUserDetailsService(aUserDetails)); + result.afterPropertiesSet(); + return result; + } + + private AuthenticationUserDetailsService getPreAuthenticatedUserDetailsService(final UserDetails aUserDetails) { + return new AuthenticationUserDetailsService() { + public UserDetails loadUserDetails(Authentication token) throws UsernameNotFoundException { + if (aUserDetails != null && aUserDetails.getUsername().equals(token.getName())) { + return aUserDetails; + } + + throw new UsernameNotFoundException("notfound"); + } + }; + } + +} diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationTokenTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationTokenTests.java index 1deebc46e3..6592e727e7 100755 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationTokenTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationTokenTests.java @@ -1,57 +1,57 @@ -package org.springframework.security.web.authentication.preauth; - -import java.util.Collection; -import java.util.List; - -import junit.framework.TestCase; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; - -/** - * - * @author TSARDD - * @since 18-okt-2007 - */ -public class PreAuthenticatedAuthenticationTokenTests extends TestCase { - - public void testPreAuthenticatedAuthenticationTokenRequestWithDetails() { - Object principal = "dummyUser"; - Object credentials = "dummyCredentials"; - Object details = "dummyDetails"; - PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken(principal, credentials); - token.setDetails(details); - assertEquals(principal, token.getPrincipal()); - assertEquals(credentials, token.getCredentials()); - assertEquals(details, token.getDetails()); - assertTrue(token.getAuthorities().isEmpty()); - } - - public void testPreAuthenticatedAuthenticationTokenRequestWithoutDetails() { - Object principal = "dummyUser"; - Object credentials = "dummyCredentials"; - PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken(principal, credentials); - assertEquals(principal, token.getPrincipal()); - assertEquals(credentials, token.getCredentials()); - assertNull(token.getDetails()); - assertTrue(token.getAuthorities().isEmpty()); - } - - public void testPreAuthenticatedAuthenticationTokenResponse() { - Object principal = "dummyUser"; - Object credentials = "dummyCredentials"; - List gas = AuthorityUtils.createAuthorityList("Role1"); - PreAuthenticatedAuthenticationToken token = - new PreAuthenticatedAuthenticationToken(principal, credentials, gas); - assertEquals(principal, token.getPrincipal()); - assertEquals(credentials, token.getCredentials()); - assertNull(token.getDetails()); - assertNotNull(token.getAuthorities()); - Collection resultColl = token.getAuthorities(); - assertTrue("GrantedAuthority collections do not match; result: " + resultColl + ", expected: " + gas, - gas.containsAll(resultColl) && resultColl.containsAll(gas)); - - } - -} +package org.springframework.security.web.authentication.preauth; + +import java.util.Collection; +import java.util.List; + +import junit.framework.TestCase; + +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; + +/** + * + * @author TSARDD + * @since 18-okt-2007 + */ +public class PreAuthenticatedAuthenticationTokenTests extends TestCase { + + public void testPreAuthenticatedAuthenticationTokenRequestWithDetails() { + Object principal = "dummyUser"; + Object credentials = "dummyCredentials"; + Object details = "dummyDetails"; + PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken(principal, credentials); + token.setDetails(details); + assertEquals(principal, token.getPrincipal()); + assertEquals(credentials, token.getCredentials()); + assertEquals(details, token.getDetails()); + assertTrue(token.getAuthorities().isEmpty()); + } + + public void testPreAuthenticatedAuthenticationTokenRequestWithoutDetails() { + Object principal = "dummyUser"; + Object credentials = "dummyCredentials"; + PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken(principal, credentials); + assertEquals(principal, token.getPrincipal()); + assertEquals(credentials, token.getCredentials()); + assertNull(token.getDetails()); + assertTrue(token.getAuthorities().isEmpty()); + } + + public void testPreAuthenticatedAuthenticationTokenResponse() { + Object principal = "dummyUser"; + Object credentials = "dummyCredentials"; + List gas = AuthorityUtils.createAuthorityList("Role1"); + PreAuthenticatedAuthenticationToken token = + new PreAuthenticatedAuthenticationToken(principal, credentials, gas); + assertEquals(principal, token.getPrincipal()); + assertEquals(credentials, token.getCredentials()); + assertNull(token.getDetails()); + assertNotNull(token.getAuthorities()); + Collection resultColl = token.getAuthorities(); + assertTrue("GrantedAuthority collections do not match; result: " + resultColl + ", expected: " + gas, + gas.containsAll(resultColl) && resultColl.containsAll(gas)); + + } + +} diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesUserDetailsServiceTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesUserDetailsServiceTests.java index d8ceb18fc4..783204d97f 100755 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesUserDetailsServiceTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesUserDetailsServiceTests.java @@ -1,73 +1,73 @@ -package org.springframework.security.web.authentication.preauth; - -import static org.junit.Assert.*; - -import java.util.List; - -import org.junit.Test; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.core.authority.GrantedAuthoritiesContainer; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; -import org.springframework.security.web.authentication.preauth.PreAuthenticatedGrantedAuthoritiesUserDetailsService; - -/** - * - * @author TSARDD - * @since 18-okt-2007 - */ -public class PreAuthenticatedGrantedAuthoritiesUserDetailsServiceTests { - - @Test(expected=IllegalArgumentException.class) - public void testGetUserDetailsInvalidType() { - PreAuthenticatedGrantedAuthoritiesUserDetailsService svc = new PreAuthenticatedGrantedAuthoritiesUserDetailsService(); - PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken("dummy", "dummy"); - token.setDetails(new Object()); - svc.loadUserDetails(token); - } - - @Test(expected=IllegalArgumentException.class) - public void testGetUserDetailsNoDetails() { - PreAuthenticatedGrantedAuthoritiesUserDetailsService svc = new PreAuthenticatedGrantedAuthoritiesUserDetailsService(); - PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken("dummy", "dummy"); - token.setDetails(null); - svc.loadUserDetails(token); - } - - @Test - public void testGetUserDetailsEmptyAuthorities() { - final String userName = "dummyUser"; - testGetUserDetails(userName, AuthorityUtils.NO_AUTHORITIES); - } - - @Test - public void testGetUserDetailsWithAuthorities() { - final String userName = "dummyUser"; - testGetUserDetails(userName, AuthorityUtils.createAuthorityList("Role1", "Role2")); - } - - private void testGetUserDetails(final String userName, final List gas) { - PreAuthenticatedGrantedAuthoritiesUserDetailsService svc = new PreAuthenticatedGrantedAuthoritiesUserDetailsService(); - PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken(userName, "dummy"); - token.setDetails(new GrantedAuthoritiesContainer() { - public List getGrantedAuthorities() { - return gas; - } - }); - UserDetails ud = svc.loadUserDetails(token); - assertTrue(ud.isAccountNonExpired()); - assertTrue(ud.isAccountNonLocked()); - assertTrue(ud.isCredentialsNonExpired()); - assertTrue(ud.isEnabled()); - assertEquals(ud.getUsername(), userName); - - //Password is not saved by - // PreAuthenticatedGrantedAuthoritiesUserDetailsService - //assertEquals(ud.getPassword(),password); - - assertTrue("GrantedAuthority collections do not match; result: " + ud.getAuthorities() + ", expected: " + gas, - gas.containsAll(ud.getAuthorities()) && ud.getAuthorities().containsAll(gas)); - } - -} +package org.springframework.security.web.authentication.preauth; + +import static org.junit.Assert.*; + +import java.util.List; + +import org.junit.Test; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.authority.GrantedAuthoritiesContainer; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; +import org.springframework.security.web.authentication.preauth.PreAuthenticatedGrantedAuthoritiesUserDetailsService; + +/** + * + * @author TSARDD + * @since 18-okt-2007 + */ +public class PreAuthenticatedGrantedAuthoritiesUserDetailsServiceTests { + + @Test(expected=IllegalArgumentException.class) + public void testGetUserDetailsInvalidType() { + PreAuthenticatedGrantedAuthoritiesUserDetailsService svc = new PreAuthenticatedGrantedAuthoritiesUserDetailsService(); + PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken("dummy", "dummy"); + token.setDetails(new Object()); + svc.loadUserDetails(token); + } + + @Test(expected=IllegalArgumentException.class) + public void testGetUserDetailsNoDetails() { + PreAuthenticatedGrantedAuthoritiesUserDetailsService svc = new PreAuthenticatedGrantedAuthoritiesUserDetailsService(); + PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken("dummy", "dummy"); + token.setDetails(null); + svc.loadUserDetails(token); + } + + @Test + public void testGetUserDetailsEmptyAuthorities() { + final String userName = "dummyUser"; + testGetUserDetails(userName, AuthorityUtils.NO_AUTHORITIES); + } + + @Test + public void testGetUserDetailsWithAuthorities() { + final String userName = "dummyUser"; + testGetUserDetails(userName, AuthorityUtils.createAuthorityList("Role1", "Role2")); + } + + private void testGetUserDetails(final String userName, final List gas) { + PreAuthenticatedGrantedAuthoritiesUserDetailsService svc = new PreAuthenticatedGrantedAuthoritiesUserDetailsService(); + PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken(userName, "dummy"); + token.setDetails(new GrantedAuthoritiesContainer() { + public List getGrantedAuthorities() { + return gas; + } + }); + UserDetails ud = svc.loadUserDetails(token); + assertTrue(ud.isAccountNonExpired()); + assertTrue(ud.isAccountNonLocked()); + assertTrue(ud.isCredentialsNonExpired()); + assertTrue(ud.isEnabled()); + assertEquals(ud.getUsername(), userName); + + //Password is not saved by + // PreAuthenticatedGrantedAuthoritiesUserDetailsService + //assertEquals(ud.getPassword(),password); + + assertTrue("GrantedAuthority collections do not match; result: " + ud.getAuthorities() + ", expected: " + gas, + gas.containsAll(ud.getAuthorities()) && ud.getAuthorities().containsAll(gas)); + } + +} diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetailsTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetailsTests.java index de9abb7fcd..39bc801887 100755 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetailsTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetailsTests.java @@ -1,62 +1,62 @@ -package org.springframework.security.web.authentication.preauth; - -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; - -import org.junit.Test; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.web.authentication.preauth.PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails; - -/** - * @author TSARDD - */ -public class PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetailsTests { - List gas = AuthorityUtils.createAuthorityList("Role1", "Role2"); - - @Test - public void testToString() { - PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails details = new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails( - getRequest("testUser", new String[] {})); - details.setGrantedAuthorities(gas); - String toString = details.toString(); - assertTrue("toString should contain Role1", toString.contains("Role1")); - assertTrue("toString should contain Role2", toString.contains("Role2")); - } - - @Test - public void testGetSetPreAuthenticatedGrantedAuthorities() { - PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails details = new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails( - getRequest("testUser", new String[] {})); - details.setGrantedAuthorities(gas); - List returnedGas = details.getGrantedAuthorities(); - assertTrue("Collections do not contain same elements; expected: " + gas + ", returned: " + returnedGas, - gas.containsAll(returnedGas) && returnedGas.containsAll(gas)); - } - - @Test(expected=IllegalArgumentException.class) - public void testGetWithoutSetPreAuthenticatedGrantedAuthorities() { - PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails details = new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails( - getRequest("testUser", new String[] {})); - details.getGrantedAuthorities(); - } - - private HttpServletRequest getRequest(final String userName,final String[] aRoles) { - MockHttpServletRequest req = new MockHttpServletRequest() { - private Set roles = new HashSet(Arrays.asList(aRoles)); - public boolean isUserInRole(String arg0) { - return roles.contains(arg0); - } - }; - req.setRemoteUser(userName); - return req; - } - -} +package org.springframework.security.web.authentication.preauth; + +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; + +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.web.authentication.preauth.PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails; + +/** + * @author TSARDD + */ +public class PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetailsTests { + List gas = AuthorityUtils.createAuthorityList("Role1", "Role2"); + + @Test + public void testToString() { + PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails details = new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails( + getRequest("testUser", new String[] {})); + details.setGrantedAuthorities(gas); + String toString = details.toString(); + assertTrue("toString should contain Role1", toString.contains("Role1")); + assertTrue("toString should contain Role2", toString.contains("Role2")); + } + + @Test + public void testGetSetPreAuthenticatedGrantedAuthorities() { + PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails details = new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails( + getRequest("testUser", new String[] {})); + details.setGrantedAuthorities(gas); + List returnedGas = details.getGrantedAuthorities(); + assertTrue("Collections do not contain same elements; expected: " + gas + ", returned: " + returnedGas, + gas.containsAll(returnedGas) && returnedGas.containsAll(gas)); + } + + @Test(expected=IllegalArgumentException.class) + public void testGetWithoutSetPreAuthenticatedGrantedAuthorities() { + PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails details = new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails( + getRequest("testUser", new String[] {})); + details.getGrantedAuthorities(); + } + + private HttpServletRequest getRequest(final String userName,final String[] aRoles) { + MockHttpServletRequest req = new MockHttpServletRequest() { + private Set roles = new HashSet(Arrays.asList(aRoles)); + public boolean isUserInRole(String arg0) { + return roles.contains(arg0); + } + }; + req.setRemoteUser(userName); + return req; + } + +} diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/header/RequestHeaderAuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/header/RequestHeaderAuthenticationFilterTests.java index cdb470d352..722f268a5a 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/header/RequestHeaderAuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/header/RequestHeaderAuthenticationFilterTests.java @@ -21,7 +21,6 @@ import org.springframework.security.web.authentication.preauth.RequestHeaderAuth /** * * @author Luke Taylor - * @version $Id$ */ public class RequestHeaderAuthenticationFilterTests { diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/j2ee/J2eePreAuthenticatedProcessingFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/j2ee/J2eePreAuthenticatedProcessingFilterTests.java index 9cba584c9d..a7d1bcb9fe 100755 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/j2ee/J2eePreAuthenticatedProcessingFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/j2ee/J2eePreAuthenticatedProcessingFilterTests.java @@ -1,50 +1,50 @@ -package org.springframework.security.web.authentication.preauth.j2ee; - -import java.security.Principal; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; - -import junit.framework.TestCase; - -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.security.web.authentication.preauth.j2ee.J2eePreAuthenticatedProcessingFilter; - -/** - * - * @author TSARDD - * @since 18-okt-2007 - */ -public class J2eePreAuthenticatedProcessingFilterTests extends TestCase { - - public final void testGetPreAuthenticatedPrincipal() { - String user = "testUser"; - assertEquals(user, new J2eePreAuthenticatedProcessingFilter().getPreAuthenticatedPrincipal( - getRequest(user,new String[] {}))); - } - - public final void testGetPreAuthenticatedCredentials() { - assertEquals("N/A", new J2eePreAuthenticatedProcessingFilter().getPreAuthenticatedCredentials( - getRequest("testUser", new String[] {}))); - } - - private final HttpServletRequest getRequest(final String aUserName,final String[] aRoles) - { - MockHttpServletRequest req = new MockHttpServletRequest() { - private Set roles = new HashSet(Arrays.asList(aRoles)); - public boolean isUserInRole(String arg0) { - return roles.contains(arg0); - } - }; - req.setRemoteUser(aUserName); - req.setUserPrincipal(new Principal() { - public String getName() { - return aUserName; - } - }); - return req; - } - -} +package org.springframework.security.web.authentication.preauth.j2ee; + +import java.security.Principal; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; + +import junit.framework.TestCase; + +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.security.web.authentication.preauth.j2ee.J2eePreAuthenticatedProcessingFilter; + +/** + * + * @author TSARDD + * @since 18-okt-2007 + */ +public class J2eePreAuthenticatedProcessingFilterTests extends TestCase { + + public final void testGetPreAuthenticatedPrincipal() { + String user = "testUser"; + assertEquals(user, new J2eePreAuthenticatedProcessingFilter().getPreAuthenticatedPrincipal( + getRequest(user,new String[] {}))); + } + + public final void testGetPreAuthenticatedCredentials() { + assertEquals("N/A", new J2eePreAuthenticatedProcessingFilter().getPreAuthenticatedCredentials( + getRequest("testUser", new String[] {}))); + } + + private final HttpServletRequest getRequest(final String aUserName,final String[] aRoles) + { + MockHttpServletRequest req = new MockHttpServletRequest() { + private Set roles = new HashSet(Arrays.asList(aRoles)); + public boolean isUserInRole(String arg0) { + return roles.contains(arg0); + } + }; + req.setRemoteUser(aUserName); + req.setUserPrincipal(new Principal() { + public String getName() { + return aUserName; + } + }); + return req; + } + +} diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/j2ee/WebXmlJ2eeDefinedRolesRetrieverTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/j2ee/WebXmlJ2eeDefinedRolesRetrieverTests.java index ee661dd4c5..c97813aeef 100755 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/j2ee/WebXmlJ2eeDefinedRolesRetrieverTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/j2ee/WebXmlJ2eeDefinedRolesRetrieverTests.java @@ -1,58 +1,58 @@ -package org.springframework.security.web.authentication.preauth.j2ee; - -import static org.junit.Assert.*; - -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -import org.junit.Test; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.core.io.ResourceLoader; - -public class WebXmlJ2eeDefinedRolesRetrieverTests { - - @Test - public void testRole1To4Roles() throws Exception { - List ROLE1TO4_EXPECTED_ROLES = Arrays.asList(new String[] { "Role1", "Role2", "Role3", "Role4" }); - final Resource webXml = new ClassPathResource("webxml/Role1-4.web.xml"); - WebXmlMappableAttributesRetriever rolesRetriever = new WebXmlMappableAttributesRetriever(); - - rolesRetriever.setResourceLoader(new ResourceLoader() { - public ClassLoader getClassLoader() { - return Thread.currentThread().getContextClassLoader(); - } - - public Resource getResource(String location) { - return webXml; - } - }); - - rolesRetriever.afterPropertiesSet(); - Set j2eeRoles = rolesRetriever.getMappableAttributes(); - assertNotNull(j2eeRoles); - assertTrue("J2eeRoles expected size: " + ROLE1TO4_EXPECTED_ROLES.size() + ", actual size: " + j2eeRoles.size(), - j2eeRoles.size() == ROLE1TO4_EXPECTED_ROLES.size()); - assertTrue("J2eeRoles expected contents (arbitrary order): " + ROLE1TO4_EXPECTED_ROLES + ", actual content: " + j2eeRoles, - j2eeRoles.containsAll(ROLE1TO4_EXPECTED_ROLES)); - } - - @Test - public void testGetZeroJ2eeRoles() throws Exception { - final Resource webXml = new ClassPathResource("webxml/NoRoles.web.xml"); - WebXmlMappableAttributesRetriever rolesRetriever = new WebXmlMappableAttributesRetriever(); - rolesRetriever.setResourceLoader(new ResourceLoader() { - public ClassLoader getClassLoader() { - return Thread.currentThread().getContextClassLoader(); - } - - public Resource getResource(String location) { - return webXml; - } - }); - rolesRetriever.afterPropertiesSet(); - Set j2eeRoles = rolesRetriever.getMappableAttributes(); - assertEquals("J2eeRoles expected size: 0, actual size: " + j2eeRoles.size(), 0, j2eeRoles.size()); - } -} +package org.springframework.security.web.authentication.preauth.j2ee; + +import static org.junit.Assert.*; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import org.junit.Test; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.core.io.ResourceLoader; + +public class WebXmlJ2eeDefinedRolesRetrieverTests { + + @Test + public void testRole1To4Roles() throws Exception { + List ROLE1TO4_EXPECTED_ROLES = Arrays.asList(new String[] { "Role1", "Role2", "Role3", "Role4" }); + final Resource webXml = new ClassPathResource("webxml/Role1-4.web.xml"); + WebXmlMappableAttributesRetriever rolesRetriever = new WebXmlMappableAttributesRetriever(); + + rolesRetriever.setResourceLoader(new ResourceLoader() { + public ClassLoader getClassLoader() { + return Thread.currentThread().getContextClassLoader(); + } + + public Resource getResource(String location) { + return webXml; + } + }); + + rolesRetriever.afterPropertiesSet(); + Set j2eeRoles = rolesRetriever.getMappableAttributes(); + assertNotNull(j2eeRoles); + assertTrue("J2eeRoles expected size: " + ROLE1TO4_EXPECTED_ROLES.size() + ", actual size: " + j2eeRoles.size(), + j2eeRoles.size() == ROLE1TO4_EXPECTED_ROLES.size()); + assertTrue("J2eeRoles expected contents (arbitrary order): " + ROLE1TO4_EXPECTED_ROLES + ", actual content: " + j2eeRoles, + j2eeRoles.containsAll(ROLE1TO4_EXPECTED_ROLES)); + } + + @Test + public void testGetZeroJ2eeRoles() throws Exception { + final Resource webXml = new ClassPathResource("webxml/NoRoles.web.xml"); + WebXmlMappableAttributesRetriever rolesRetriever = new WebXmlMappableAttributesRetriever(); + rolesRetriever.setResourceLoader(new ResourceLoader() { + public ClassLoader getClassLoader() { + return Thread.currentThread().getContextClassLoader(); + } + + public Resource getResource(String location) { + return webXml; + } + }); + rolesRetriever.afterPropertiesSet(); + Set j2eeRoles = rolesRetriever.getMappableAttributes(); + assertEquals("J2eeRoles expected size: 0, actual size: " + j2eeRoles.size(), 0, j2eeRoles.size()); + } +} diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/websphere/WebSphere2SpringSecurityPropagationInterceptorTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/websphere/WebSphere2SpringSecurityPropagationInterceptorTests.java index 914703e6d8..4963b52d4e 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/websphere/WebSphere2SpringSecurityPropagationInterceptorTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/websphere/WebSphere2SpringSecurityPropagationInterceptorTests.java @@ -21,7 +21,6 @@ import org.springframework.security.web.authentication.preauth.PreAuthenticatedA /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class WebSphere2SpringSecurityPropagationInterceptorTests { diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/x509/SubjectDnX509PrincipalExtractorTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/x509/SubjectDnX509PrincipalExtractorTests.java index 83e82325e2..efce877653 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/x509/SubjectDnX509PrincipalExtractorTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/x509/SubjectDnX509PrincipalExtractorTests.java @@ -11,7 +11,6 @@ import static junit.framework.Assert.*; /** * @author Luke Taylor - * @version $Id$ */ public class SubjectDnX509PrincipalExtractorTests { SubjectDnX509PrincipalExtractor extractor; diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/x509/X509TestUtils.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/x509/X509TestUtils.java index 883c2d20ea..da0af061c4 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/x509/X509TestUtils.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/x509/X509TestUtils.java @@ -25,7 +25,6 @@ import java.security.cert.X509Certificate; * Certificate creation utility for use in X.509 tests. * * @author Luke Taylor - * @version $Id$ */ public class X509TestUtils { //~ Methods ======================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java b/web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java index 52db03d700..0c80c3a7f6 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java @@ -24,7 +24,6 @@ import org.springframework.util.StringUtils; /** * @author Luke Taylor - * @version $Id$ */ public class AbstractRememberMeServicesTests { static User joe = new User("joe", "password", true, true,true,true, AuthorityUtils.createAuthorityList("ROLE_A")); diff --git a/web/src/test/java/org/springframework/security/web/authentication/rememberme/JdbcTokenRepositoryImplTests.java b/web/src/test/java/org/springframework/security/web/authentication/rememberme/JdbcTokenRepositoryImplTests.java index 9a4a6aa5fc..1d2eefe310 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/rememberme/JdbcTokenRepositoryImplTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/rememberme/JdbcTokenRepositoryImplTests.java @@ -17,7 +17,6 @@ import org.springframework.jdbc.datasource.SingleConnectionDataSource; /** * @author Luke Taylor - * @version $Id$ */ @SuppressWarnings("unchecked") public class JdbcTokenRepositoryImplTests { diff --git a/web/src/test/java/org/springframework/security/web/authentication/rememberme/NullRememberMeServicesTests.java b/web/src/test/java/org/springframework/security/web/authentication/rememberme/NullRememberMeServicesTests.java index c7759be50a..55b96dc793 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/rememberme/NullRememberMeServicesTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/rememberme/NullRememberMeServicesTests.java @@ -24,7 +24,6 @@ import junit.framework.TestCase; * Tests {@link org.springframework.security.web.authentication.NullRememberMeServices}. * * @author Ben Alex - * @version $Id$ */ public class NullRememberMeServicesTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/authentication/rememberme/PersistentTokenBasedRememberMeServicesTests.java b/web/src/test/java/org/springframework/security/web/authentication/rememberme/PersistentTokenBasedRememberMeServicesTests.java index 7b4375876b..6aa0a229f5 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/rememberme/PersistentTokenBasedRememberMeServicesTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/rememberme/PersistentTokenBasedRememberMeServicesTests.java @@ -21,7 +21,6 @@ import org.springframework.security.web.authentication.rememberme.RememberMeAuth /** * @author Luke Taylor - * @version $Id$ */ public class PersistentTokenBasedRememberMeServicesTests { private PersistentTokenBasedRememberMeServices services; @@ -121,7 +120,7 @@ public class PersistentTokenBasedRememberMeServicesTests { Cookie returnedCookie = response.getCookie("mycookiename"); assertNotNull(returnedCookie); assertEquals(0, returnedCookie.getMaxAge()); - + // SEC-1280 services.logout(request, response, null); } diff --git a/web/src/test/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationFilterTests.java index 6120499428..33586ca878 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationFilterTests.java @@ -48,7 +48,6 @@ import org.springframework.security.web.authentication.RememberMeServices; * Tests {@link RememberMeAuthenticationFilter}. * * @author Ben Alex - * @version $Id$ */ public class RememberMeAuthenticationFilterTests extends TestCase { Authentication remembered = new TestingAuthenticationToken("remembered", "password","ROLE_REMEMBERED"); diff --git a/web/src/test/java/org/springframework/security/web/authentication/rememberme/TokenBasedRememberMeServicesTests.java b/web/src/test/java/org/springframework/security/web/authentication/rememberme/TokenBasedRememberMeServicesTests.java index 0544fc4be8..34fb3a2f0f 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/rememberme/TokenBasedRememberMeServicesTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/rememberme/TokenBasedRememberMeServicesTests.java @@ -45,7 +45,6 @@ import org.springframework.util.StringUtils; * Tests {@link org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices}. * * @author Ben Alex - * @version $Id$ */ public class TokenBasedRememberMeServicesTests { private Mockery jmock = new JUnit4Mockery(); diff --git a/web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilterTests.java index 645f43421b..1f572a6903 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/switchuser/SwitchUserFilterTests.java @@ -56,7 +56,6 @@ import org.springframework.security.web.authentication.switchuser.SwitchUserFilt * * @author Mark St.Godard * @author Luke Taylor - * @version $Id$ */ public class SwitchUserFilterTests { private final static List ROLES_12 = AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"); diff --git a/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPointTests.java b/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPointTests.java index 8cd69e2480..851996cea8 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPointTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationEntryPointTests.java @@ -27,7 +27,6 @@ import org.springframework.mock.web.MockHttpServletResponse; * Tests {@link BasicAuthenticationEntryPoint}. * * @author Ben Alex - * @version $Id$ */ public class BasicAuthenticationEntryPointTests extends TestCase { //~ Constructors =================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilterTests.java index 88bb1f3755..a9d4b20ba3 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilterTests.java @@ -49,7 +49,6 @@ import org.springframework.security.web.authentication.WebAuthenticationDetails; * Tests {@link BasicAuthenticationFilter}. * * @author Ben Alex - * @version $Id$ */ public class BasicAuthenticationFilterTests { //~ Instance fields ================================================================================================ diff --git a/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthUtilsTests.java b/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthUtilsTests.java index 7c9449bcb1..0f0667dcc9 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthUtilsTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthUtilsTests.java @@ -26,7 +26,6 @@ import java.util.Map; * Tests {@link org.springframework.security.util.StringSplitUtils}. * * @author Ben Alex - * @version $Id$ */ public class DigestAuthUtilsTests extends TestCase { //~ Constructors =================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthenticationEntryPointTests.java b/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthenticationEntryPointTests.java index 7b491354e0..7124f6db30 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthenticationEntryPointTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthenticationEntryPointTests.java @@ -31,7 +31,6 @@ import org.springframework.util.StringUtils; * Tests {@link DigestAuthenticationEntryPoint}. * * @author Ben Alex - * @version $Id$ */ public class DigestAuthenticationEntryPointTests extends TestCase { //~ Methods ======================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthenticationFilterTests.java index 291d354832..2116d1d24b 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/www/DigestAuthenticationFilterTests.java @@ -50,7 +50,6 @@ import org.springframework.util.StringUtils; * * @author Ben Alex * @author Luke Taylor - * @version $Id$ */ public class DigestAuthenticationFilterTests { //~ Static fields/initializers ===================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/context/HttpSessionContextIntegrationFilterTests.java b/web/src/test/java/org/springframework/security/web/context/HttpSessionContextIntegrationFilterTests.java index 19acac2441..9be42a694f 100644 --- a/web/src/test/java/org/springframework/security/web/context/HttpSessionContextIntegrationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/context/HttpSessionContextIntegrationFilterTests.java @@ -41,7 +41,6 @@ import org.springframework.security.core.context.SecurityContextImpl; * Tests {@link HttpSessionContextIntegrationFilter}. * * @author Ben Alex - * @version $Id$ */ @SuppressWarnings("deprecation") public class HttpSessionContextIntegrationFilterTests { diff --git a/web/src/test/java/org/springframework/security/web/savedrequest/HttpSessionRequestCacheTests.java b/web/src/test/java/org/springframework/security/web/savedrequest/HttpSessionRequestCacheTests.java index 802f8939fa..a0486521a3 100644 --- a/web/src/test/java/org/springframework/security/web/savedrequest/HttpSessionRequestCacheTests.java +++ b/web/src/test/java/org/springframework/security/web/savedrequest/HttpSessionRequestCacheTests.java @@ -9,7 +9,6 @@ import org.springframework.mock.web.MockHttpServletResponse; /** * * @author Luke Taylor - * @version $Id$ * @since 3.0 */ public class HttpSessionRequestCacheTests { diff --git a/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilterTests.java b/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilterTests.java index 9ae7ce0728..d3d2a4bd98 100644 --- a/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilterTests.java @@ -32,7 +32,6 @@ import org.springframework.security.web.servletapi.SecurityContextHolderAwareReq * Tests {@link SecurityContextHolderAwareRequestFilter}. * * @author Ben Alex - * @version $Id$ */ public class SecurityContextHolderAwareRequestFilterTests { Mockery jmock = new JUnit4Mockery(); diff --git a/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestWrapperTests.java b/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestWrapperTests.java index 915d25f3fa..2e082b1a5b 100644 --- a/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestWrapperTests.java +++ b/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestWrapperTests.java @@ -29,7 +29,6 @@ import org.springframework.security.web.servletapi.SecurityContextHolderAwareReq * Tests {@link SecurityContextHolderAwareRequestWrapper}. * * @author Ben Alex - * @version $Id$ */ public class SecurityContextHolderAwareRequestWrapperTests extends TestCase { diff --git a/web/src/test/java/org/springframework/security/web/session/DefaultSessionAuthenticationStrategyTests.java b/web/src/test/java/org/springframework/security/web/session/DefaultSessionAuthenticationStrategyTests.java index 250f696c52..7b45d149f6 100644 --- a/web/src/test/java/org/springframework/security/web/session/DefaultSessionAuthenticationStrategyTests.java +++ b/web/src/test/java/org/springframework/security/web/session/DefaultSessionAuthenticationStrategyTests.java @@ -16,7 +16,6 @@ import org.springframework.security.web.savedrequest.DefaultSavedRequest; /** * * @author Luke Taylor - * @version $Id$ */ public class DefaultSessionAuthenticationStrategyTests { diff --git a/web/src/test/java/org/springframework/security/web/session/HttpSessionEventPublisherTests.java b/web/src/test/java/org/springframework/security/web/session/HttpSessionEventPublisherTests.java index 7ee44ae9be..ff0a4ae2dc 100644 --- a/web/src/test/java/org/springframework/security/web/session/HttpSessionEventPublisherTests.java +++ b/web/src/test/java/org/springframework/security/web/session/HttpSessionEventPublisherTests.java @@ -30,7 +30,6 @@ import org.springframework.web.context.support.StaticWebApplicationContext; * The HttpSessionEventPublisher tests * * @author Ray Krueger - * @version $Id$ */ public class HttpSessionEventPublisherTests { //~ Methods ======================================================================================================== diff --git a/web/src/test/java/org/springframework/security/web/util/TextEscapeUtilsTests.java b/web/src/test/java/org/springframework/security/web/util/TextEscapeUtilsTests.java index c35766c5a8..2a05e2f1e5 100644 --- a/web/src/test/java/org/springframework/security/web/util/TextEscapeUtilsTests.java +++ b/web/src/test/java/org/springframework/security/web/util/TextEscapeUtilsTests.java @@ -11,5 +11,5 @@ public class TextEscapeUtilsTests { public void charactersAreEscapedCorrectly() { assertEquals("a<script>"'", TextEscapeUtils.escapeEntities("a