You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by lh...@apache.org on 2014/06/01 19:33:34 UTC

svn commit: r1599014 [1/4] - in /shiro/branches/2.0-api-design-changes: ./ cache/src/main/java/org/apache/shiro/cache/ core/src/main/java/org/apache/shiro/account/ core/src/main/java/org/apache/shiro/authc/ core/src/main/java/org/apache/shiro/authc/cre...

Author: lhazlewood
Date: Sun Jun  1 17:33:31 2014
New Revision: 1599014

URL: http://svn.apache.org/r1599014
Log:
Big progress on 2.0 design changes.  Finally! WOOT!

Added:
    shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/DisabledCacheManager.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/Account.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/AccountId.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/AccountStore.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AuthenticationEvent.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/CompositeAccount.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/CompositeAccountId.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultAuthenticator.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultCompositeAccount.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultCompositeAccountId.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/FailedAuthenticationEvent.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SuccessfulAuthenticationEvent.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/strategy/
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/strategy/AllRealmsSuccessfulStrategy.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/strategy/AtLeastOneRealmSuccessfulStrategy.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/strategy/AuthenticationAttempt.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/strategy/AuthenticationStrategy.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/strategy/DefaultAuthenticationAttempt.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/strategy/FirstRealmSuccessfulStrategy.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/strategy/MultiRealmAuthenticationException.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/strategy/package-info.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/mgt/ApplicationSecurityManager.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/AbstractCacheHandler.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/AccountCacheHandler.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/AccountCacheKeyResolver.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/AccountCacheResolver.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/AccountPermissionResolver.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/AccountRolePermissionResolver.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/AccountRoleResolver.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/AccountStoreRealm.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/AuthorizationCacheHandler.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/DefaultAccountCacheHandler.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/RealmAccount.java
Modified:
    shiro/branches/2.0-api-design-changes/RELEASE-NOTES
    shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/Cache.java
    shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/CacheManagerAware.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AbstractAuthenticator.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/Account.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AuthenticationInfo.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/Authenticator.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/MergableAuthenticationInfo.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SaltedAuthenticationInfo.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SimpleAccount.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SimpleAuthenticationInfo.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcher.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/CredentialsMatcher.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/DefaultPasswordService.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/HashedCredentialsMatcher.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Md2CredentialsMatcher.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Md5CredentialsMatcher.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/PasswordMatcher.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/PasswordService.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Sha1CredentialsMatcher.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Sha256CredentialsMatcher.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Sha384CredentialsMatcher.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Sha512CredentialsMatcher.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/SimpleCredentialsMatcher.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/pam/AbstractAuthenticationStrategy.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/pam/AllSuccessfulStrategy.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/pam/AtLeastOneSuccessfulStrategy.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/pam/AuthenticationStrategy.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/pam/FirstSuccessfulStrategy.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/pam/ModularRealmAuthenticator.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/pam/UnsupportedTokenException.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/pam/package-info.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authz/AuthorizationInfo.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authz/Authorizer.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/mgt/AuthenticatingSecurityManager.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/mgt/AuthorizingSecurityManager.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/mgt/CachingSecurityManager.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/mgt/RealmSecurityManager.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/mgt/SessionsSecurityManager.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/AuthenticatingRealm.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/AuthorizingRealm.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/CachingRealm.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/Realm.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/SimpleAccountRealm.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/activedirectory/ActiveDirectoryRealm.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/jdbc/JdbcRealm.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/ldap/AbstractLdapRealm.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/ldap/JndiLdapRealm.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/text/IniRealm.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/text/PropertiesRealm.java
    shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/realm/text/TextConfigurationRealm.java
    shiro/branches/2.0-api-design-changes/core/src/test/groovy/org/apache/shiro/realm/CachingRealmTest.groovy
    shiro/branches/2.0-api-design-changes/core/src/test/java/org/apache/shiro/authc/AbstractAuthenticatorTest.java
    shiro/branches/2.0-api-design-changes/core/src/test/java/org/apache/shiro/realm/activedirectory/ActiveDirectoryRealmTest.java
    shiro/branches/2.0-api-design-changes/samples/spring/src/main/java/org/apache/shiro/samples/spring/realm/SaltAwareJdbcRealm.java
    shiro/branches/2.0-api-design-changes/support/cas/src/main/java/org/apache/shiro/cas/CasRealm.java
    shiro/branches/2.0-api-design-changes/support/openid4j/src/main/java/org/apache/shiro/openid4j/realm/RelyingPartyRealm.java

Modified: shiro/branches/2.0-api-design-changes/RELEASE-NOTES
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/RELEASE-NOTES?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/RELEASE-NOTES (original)
+++ shiro/branches/2.0-api-design-changes/RELEASE-NOTES Sun Jun  1 17:33:31 2014
@@ -21,6 +21,129 @@ combined with Jira's auto-generated rele
 total set.
 
 ###########################################################
+# 2.0 alpha 0
+###########################################################
+
+The 2.0 alpha 0 release's design goal is to introduce a much cleaner, more intuitive, more configurable API that is
+even easier to understand and use than previous Shiro versions.
+
+The design changes however introduce enough change such that there will be a decent amount of deprecation of old
+concepts and implementations; the releases before 2.0.0 final will retain all of these 'legacy' concepts and
+implementations to provide a smoother upgrade path for those trying alpha and beta releases.
+
+2.0.0 final however will completely remove all deprecated interfaces, classes and methods to ensure a clean
+codebase for the many years to come.
+
+Design Changes
+--------------------------------
+
+- All of Shiro's SecurityManager implementations now require a CacheManager - it cannot be null.  Caching is still
+  disabled by default however; the SecurityManager implementations just default to an
+  org.apache.shiro.cache.DisabledCacheManager instance.  This reflects the Null Object design pattern, helping
+  reducing cyclomatic complexity (and therefore the potential for bugs) in Shiro.
+
+- org.apache.shiro.subject.PrincipalCollection has been deprecated and will be removed in 2.0 final.  This represents
+  a big change, but for an extremely strong reason:
+
+  Almost all Shiro end-users expect to be able to query a Subject's PrincipalCollection for identifying attributes,
+  like a username, or first name, etc.  This is extraordinarily difficult with the PrincipalCollection API, which
+  only allows users to acquire identity attributes _by type_.  If you had more than one attribute of the same
+  type (e.g. a String username and a String surname), the PrincipalCollection is effectively useless, and you had to
+  come up with all sorts of workarounds (like creating 'wrapper' objects) to obtain the data you needed.  Additionally
+  these workarounds were not usable by any tools or frameworks that used reflection to lookup information.
+
+  This was a huge problem, almost crippling in some cases, and so PrincipalCollection has been deprecated and
+  replaced by a very simple 'attributes' map, of type Map<String,Object>.  This allows much cleaner code, like:
+
+  subject.getAttributes().get("username");
+
+  or, even simpler for Groovy or JSTL:
+
+  subject.attributes[username]
+
+  This change affords a huge number of simplifications/conveniences for the Shriro user community, dev team, and
+  bean-compatible tools and frameworks.
+
+- org.apache.shiro.authc.AuthenticationInfo (used widely by Realm implementations) has been deprecated and will be
+  replaced by a brand new org.apache.shiro.account.Account interface.  This was done for three reasons:
+
+  1. Account supports a getId() method, which allows explicit support for a data-store-unique account identifier.
+     AuthenticationInfo did not have this, and id acquisition was implicit - not good for such a core Shiro concept.
+
+  2. 'Account' is an inherently more intuitive name.  The < 2.0 'AuthenticationInfo' interface name actually always
+     represented an Account, and the name 'AuthenticationInfo' is abstract and fairly unintuitive.  Now it is more
+     obvious/explicity.
+
+  3. Shiro's old PrincipalCollection concept is being removed.  Account instead represents principals with a
+     new name, called 'attributes' as a simple Map<String,Object> collections, as described above.
+
+  org.apache.shiro.authc.AuthenticationInfo is currently deprecated, but will be removed entirely when 2.0 final is
+  released.
+
+- The previously (very) complicated SecurityManager implementation hierarchy has been deprecated entirely:
+
+  CachingSecurityManager < RealmSecurityManager < AuthenticatingSecurityManager < AuthorizingSecurityManager
+      < SessionsSecurityManager < DefaultSecurityManager < DefaultWebSecurityManager
+
+  An interim replacement, org.apache.shiro.mgt.ApplicationSecurityManager is the only SecurityManager implementation.
+  All customization for this implementation can be done by customizing or plugging in its internal components.  This is
+  now possible because the implementation much more heavily favors a "delegation over inheritance" best practice.
+  This approach will allow much greater resilience to change over time and help keep Shiro's core SecurityManager
+  codebase highly stable.
+
+  Right before the 2.0 final release, ApplicationSecurityManager might be renamed to DefaultSecurityManager to adhere
+  to all other existing default implementation naming conventions.  This just cannot be done prior to a 2.0 final
+  release because it would be a backwards-incompatible change.
+
+- For multi-realm authentication, the org.apache.shiro.authc.pam package and all of its internal
+  org.apache.shiro.authc.pam.AuthenticationStrategy implementations have been deprecated in favor of the new
+  org.apache.shiro.authc.strategy package.
+
+  The new org.apache.shiro.authc.strategy.AuthenticationStrategy interface is much simpler - it is a single method that
+  can perform all multi-realm interaction logic without compromise.
+
+  The legacy org.apache.shiro.authc.pam.AuthenticationStrategy API and implementations suffered from an overly complex
+  pre/before/after/post implementation requirement, and in some cases, entirely prevented some Strategy behavior from
+  being implemented successfully.
+
+  For example the org.apache.shiro.authc.pam.FirstSuccessfulStrategy did not
+  short-circuit realm iteration (desired by most Shiro users) and the existing Strategy API provided no way to 'tell'
+  the calling Authorizer how to stop iteration when things were successful.  The new Strategy API has no such problems,
+  and is more holistic, allowing implementors exact control over the login attempt.
+
+  Finally, the *Strategy implementations have been renamed to include the word 'Realm' in the name to more explicitly
+  self-document what is occurring.
+
+  For example, the class name 'FirstRealmSuccessfulStrategy' (in 2.0) is more intuitive than
+  'FirstSuccessfulStrategy' in pre 2.0 (first *what* is successful?).  The 2.0 implementations naming scheme makes it
+  very clear what is occurring.
+
+- org.apache.shiro.authc.AuthenticationInfo (used widely by Realms) has been deprecated in favor of a
+
+Deprecations (will be removed immediately before 2.0 final)
+-----------------------------------------------------------
+
+- org.apache.shiro.cache.Cache methods clear(), size() and keys() have been deprecated and will be removed before the
+  2.0 final release.  These methods were never called by Shiro's components and caused an unnecessary implementation
+  burden.
+
+- org.apache.shiro.authc.credential.CredentialsMatcher doCredentialsMatch(AuthenticationToken, AuthenticationInfo)
+  has been deprecated in favor of the new method (in the same interface):
+  credentialsMatch(AuthenticationToken, Account) to reflect the new Account concept (discussed in 'Design Changes'
+  above).
+
+- org.apache.shiro.authc.credential.HashedCredentialsMatcher and all of its children implementations
+  (Md5CredentialsMatcher, Sha256CredentialsMatcher, etc) have been deprecated and will be removed in 2.0 final.  The
+  org.apache.shiro.authc.credential.PasswordMatcher and org.apache.shiro.authc.credential.PasswordService
+  introduced in 1.2 perform all of these operations and more.
+
+New Features / Implementations
+--------------------------------
+- org.apache.shiro.cache.DisabledCacheManager returns no-op implementations for all caching operations.  Mostly usable
+  for the Null Object design pattern.
+
+
+###########################################################
 # 1.2.0
 ###########################################################
 

Modified: shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/Cache.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/Cache.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/Cache.java (original)
+++ shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/Cache.java Sun Jun  1 17:33:31 2014
@@ -48,7 +48,7 @@ public interface Cache<K, V> {
      *
      * @param key   the key used to identify the object being stored.
      * @param value the value to be stored in the cache.
-     * @return the previous value associated with the given {@code key} or {@code null} if there was previous value
+     * @return the previous value associated with the given {@code key} or {@code null} if there was no previous value
      * @throws CacheException if there is a problem accessing the underlying cache system
      */
     public V put(K key, V value) throws CacheException;
@@ -57,7 +57,7 @@ public interface Cache<K, V> {
      * Remove the cache entry corresponding to the specified key.
      *
      * @param key the key of the entry to be removed.
-     * @return the previous value associated with the given {@code key} or {@code null} if there was previous value
+     * @return the previous value associated with the given {@code key} or {@code null} if there was no previous value
      * @throws CacheException if there is a problem accessing the underlying cache system
      */
     public V remove(K key) throws CacheException;
@@ -66,21 +66,27 @@ public interface Cache<K, V> {
      * Clear all entries from the cache.
      *
      * @throws CacheException if there is a problem accessing the underlying cache system
+     * @deprecated since 2.0.  Shiro's implementations never called this method - it is extraneous and causes unnecessary implementation requirements on Cache implementors.
      */
+    @Deprecated
     public void clear() throws CacheException;
 
     /**
      * Returns the number of entries in the cache.
      *
      * @return the number of entries in the cache.
+     * @deprecated since 2.0.  Shiro's implementations never called this method - it is extraneous and causes unnecessary implementation requirements on Cache implementors.
      */
+    @Deprecated
     public int size();
 
     /**
      * Returns a view of all the keys for entries contained in this cache.
      *
      * @return a view of all the keys for entries contained in this cache.
+     * @deprecated since 2.0.  Shiro's implementations never called this method - it is extraneous and causes unnecessary implementation requirements on Cache implementors.
      */
+    @Deprecated
     public Set<K> keys();
 
     /**

Modified: shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/CacheManagerAware.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/CacheManagerAware.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/CacheManagerAware.java (original)
+++ shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/CacheManagerAware.java Sun Jun  1 17:33:31 2014
@@ -23,7 +23,7 @@ package org.apache.shiro.cache;
  * one is available.
  *
  * <p>This is used so internal security components that use a CacheManager can be injected with it instead of having
- * to create one on their own.
+ * to create one on their own.</p>
  *
  * @since 0.9
  */

Added: shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/DisabledCacheManager.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/DisabledCacheManager.java?rev=1599014&view=auto
==============================================================================
--- shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/DisabledCacheManager.java (added)
+++ shiro/branches/2.0-api-design-changes/cache/src/main/java/org/apache/shiro/cache/DisabledCacheManager.java Sun Jun  1 17:33:31 2014
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.shiro.cache;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * A {@code CacheManager} implementation that does not perform any caching at all.  While at first glance this concept
+ * might sound odd, it reflects the <a href="http://en.wikipedia.org/wiki/Null_Object_pattern">Null Object Design
+ * Pattern</a>: other parts of Shiro or users' code do not need to perform null checks when interacting with Cache or
+ * CacheManager instances, reducing code verbosity, enhancing readability, and reducing probability for certain bugs.
+ *
+ * @since 2.0
+ */
+public class DisabledCacheManager implements CacheManager {
+
+    public static final DisabledCacheManager INSTANCE = new DisabledCacheManager();
+
+    private static final Cache DISABLED_CACHE = new DisabledCache();
+
+    @SuppressWarnings("unchecked")
+    public <K, V> Cache<K, V> getCache(String name) throws CacheException {
+        return DISABLED_CACHE;
+    }
+
+    private static final class DisabledCache<K,V> implements Cache<K,V> {
+
+        public V get(K key) throws CacheException {
+            return null;
+        }
+
+        public V put(K key, V value) throws CacheException {
+            return null;
+        }
+
+        public V remove(K key) throws CacheException {
+            return null;
+        }
+
+        public void clear() throws CacheException {
+        }
+
+        public int size() {
+            return 0;
+        }
+
+        public Set<K> keys() {
+            return Collections.emptySet();
+        }
+
+        public Collection<V> values() {
+            return Collections.emptySet();
+        }
+    }
+}

Added: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/Account.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/Account.java?rev=1599014&view=auto
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/Account.java (added)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/Account.java Sun Jun  1 17:33:31 2014
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.shiro.account;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * An {@code Account} is a unique identity within an {@link AccountStore AccountStore} that
+ * has a set of attributes.  An account may represent a human being, but this is not required - an account could
+ * represent a host, a server, a daemon - basically anything with an identity that might need to be authenticated or
+ * authorized to perform behavior.
+ * <h3>Implementation Warning</h3>
+ * Since Shiro sometimes logs account operations, please ensure your Account's <code>toString()</code>
+ * implementation does <em>not</em> print out account credentials (password, etc), as these might be viewable to
+ * someone reading your logs.  This is good practice anyway, and account principals should rarely (if ever) be printed
+ * out for any reason.
+ * <p/>
+ * Shiro's default implementations of this interface only ever print {@link #getAttributes() attributes}.
+ *
+ * @since 2.0
+ */
+public interface Account extends Serializable {
+
+    /**
+     * Returns an identifier unique compared to any other Account found in the same account store.  For example,
+     * this can be a store-wide unique username or email address, database primary key, UUID, GUID, etc.
+     * <p/>
+     * After an account is authenticated, Shiro will use this id for all future access to the account: for caching
+     * the account (if caching is enabled), for future lookups from the account store, and any lookups for authorization.
+     *
+     * @return an identifier unique compared to any other Account found in the same account store.
+     */
+    AccountId getId();
+
+    /**
+     * Returns the stored credentials associated with the corresponding Account.  Credentials, such as a password or
+     * private key, verifies one or more submitted identities during authentication.
+     * <p/>
+     * Shiro references credentials during the authentication process to ensure that submitted credentials
+     * during a login attempt match exactly the Account's stored credentials returned via this method.
+     *
+     * @return the credentials associated with the corresponding Subject.
+     */
+    Object getCredentials();
+
+    /**
+     * Returns an <b><em>immutable</em></b> view of the Account's attributes accessible to the application.
+     * Once the account is obtained, an application developer can access them as desired, for example:
+     * <pre>
+     * String username = (String)account.getAttributes().get("username");
+     * System.out.println("Welcome, " + username + "!");
+     * </pre>
+     *
+     * @return the Account's attributes accessible to the application.
+     */
+    Map<String, Object> getAttributes();
+
+}

Added: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/AccountId.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/AccountId.java?rev=1599014&view=auto
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/AccountId.java (added)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/AccountId.java Sun Jun  1 17:33:31 2014
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.shiro.account;
+
+import java.io.Serializable;
+
+/**
+ * @since 2.0
+ */
+public interface AccountId extends Serializable {
+
+    String toString();
+}

Added: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/AccountStore.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/AccountStore.java?rev=1599014&view=auto
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/AccountStore.java (added)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/account/AccountStore.java Sun Jun  1 17:33:31 2014
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.shiro.account;
+
+import org.apache.shiro.authc.AuthenticationToken;
+
+/**
+ * @since 2.0
+ */
+public interface AccountStore {
+
+    Account getAccount(AuthenticationToken token);
+
+    Account getAccount(AccountId id);
+
+}

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AbstractAuthenticator.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AbstractAuthenticator.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AbstractAuthenticator.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AbstractAuthenticator.java Sun Jun  1 17:33:31 2014
@@ -39,7 +39,9 @@ import java.util.Collection;
  * is perform the actual principal/credential verification process for the submitted {@code AuthenticationToken}.
  *
  * @since 0.1
+ * @deprecated since 2.0 in favor of {@link DefaultAuthenticator} or implementing {@link Authenticator} directly.
  */
+@Deprecated
 public abstract class AbstractAuthenticator implements Authenticator, LogoutAware {
 
     /*-------------------------------------------
@@ -185,6 +187,7 @@ public abstract class AbstractAuthentica
      * @throws AuthenticationException if there is any problem during the authentication process - see the
      *                                 interface's JavaDoc for a more detailed explanation.
      */
+    @Deprecated
     public final AuthenticationInfo authenticate(AuthenticationToken token) throws AuthenticationException {
 
         if (token == null) {
@@ -254,6 +257,4 @@ public abstract class AbstractAuthentica
      */
     protected abstract AuthenticationInfo doAuthenticate(AuthenticationToken token)
             throws AuthenticationException;
-
-
 }

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/Account.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/Account.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/Account.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/Account.java Sun Jun  1 17:33:31 2014
@@ -36,7 +36,9 @@ import org.apache.shiro.authz.Authorizat
  *
  * @see SimpleAccount
  * @since 0.9
+ * @deprecated since 2.0 in favor of {@link org.apache.shiro.account.Account}
  */
+@Deprecated
 public interface Account extends AuthenticationInfo, AuthorizationInfo {
 
 }

Added: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AuthenticationEvent.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AuthenticationEvent.java?rev=1599014&view=auto
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AuthenticationEvent.java (added)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AuthenticationEvent.java Sun Jun  1 17:33:31 2014
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.shiro.authc;
+
+import org.apache.shiro.event.Event;
+
+/**
+ * @since 2.0
+ */
+public abstract class AuthenticationEvent extends Event {
+
+    private final AuthenticationToken token;
+
+    public AuthenticationEvent(Object source, AuthenticationToken token) {
+        super(source);
+        this.token = token;
+    }
+
+    public AuthenticationToken getAuthenticationToken() {
+        return token;
+    }
+}

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AuthenticationInfo.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AuthenticationInfo.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AuthenticationInfo.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/AuthenticationInfo.java Sun Jun  1 17:33:31 2014
@@ -54,7 +54,9 @@ import java.io.Serializable;
  * @see org.apache.shiro.authz.AuthorizationInfo AuthorizationInfo
  * @see Account
  * @since 0.9
+ * @deprecated since 2.0 in favor of {@link org.apache.shiro.account.Account}.
  */
+@Deprecated
 public interface AuthenticationInfo extends Serializable {
 
     /**
@@ -66,7 +68,9 @@ public interface AuthenticationInfo exte
      * as passwords, private keys, etc.  Those should be instead returned by {@link #getCredentials() getCredentials()}.
      *
      * @return all principals associated with the corresponding Subject.
+     * @deprecated since 2.0 in favor of {@link org.apache.shiro.account.Account#getAttributes()}.
      */
+    @Deprecated
     PrincipalCollection getPrincipals();
 
     /**

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/Authenticator.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/Authenticator.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/Authenticator.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/Authenticator.java Sun Jun  1 17:33:31 2014
@@ -19,12 +19,11 @@
 package org.apache.shiro.authc;
 
 /**
- * An Authenticator is responsible for authenticating accounts in an application.  It
- * is one of the primary entry points into the Shiro API.
+ * An Authenticator is responsible for authenticating accounts.
  * <p/>
  * Although not a requirement, there is usually a single 'master' Authenticator configured for
  * an application.  Enabling Pluggable Authentication Module (PAM) behavior
- * (Two Phase Commit, etc.) is usually achieved by the single {@code Authenticator} coordinating
+ * (Two Phase Commit, etc.) is usually achieved by the master {@code Authenticator} coordinating
  * and interacting with an application-configured set of {@link org.apache.shiro.realm.Realm Realm}s.
  * <p/>
  * Note that most Shiro users will not interact with an {@code Authenticator} instance directly.
@@ -39,7 +38,7 @@ package org.apache.shiro.authc;
 public interface Authenticator {
 
     /**
-     * Authenticates a user based on the submitted {@code AuthenticationToken}.
+     * Authenticates an account based on the submitted {@code AuthenticationToken}.
      * <p/>
      * If the authentication is successful, an {@link AuthenticationInfo} instance is returned that represents the
      * user's account data relevant to Shiro.  This returned object is generally used in turn to construct a
@@ -61,7 +60,35 @@ public interface Authenticator {
      * @see LockedAccountException
      * @see ConcurrentAccessException
      * @see UnknownAccountException
+     * @deprecated since 2.0 in favor of {@link #authenticateAccount(AuthenticationToken)}.
      */
-    public AuthenticationInfo authenticate(AuthenticationToken authenticationToken)
-            throws AuthenticationException;
+    @Deprecated
+    public AuthenticationInfo authenticate(AuthenticationToken authenticationToken) throws AuthenticationException;
+
+    /**
+     * Authenticates an account based on the submitted {@code AuthenticationToken}.
+     * <p/>
+     * If the authentication is successful, the {@link Account} instance representing data relevant to Shiro is
+     * returned.  The returned account is used by higher-level components to construct a
+     * {@code Subject} representing a more complete security-specific 'view' of an account that also allows access to
+     * a {@code Session}.
+     *
+     * @param authenticationToken any representation of an account's principals and credentials submitted during an
+     *                            authentication attempt.
+     * @return the authenticated account.
+     * @throws AuthenticationException if there is any problem during the authentication process.
+     *                                 See the specific exceptions listed below to as examples of what could happen
+     *                                 in order to accurately handle these problems and to notify the user in an
+     *                                 appropriate manner why the authentication attempt failed.  Realize an
+     *                                 implementation of this interface may or may not throw those listed or may
+     *                                 throw other AuthenticationExceptions, but the list shows the most common ones.
+     * @see ExpiredCredentialsException
+     * @see IncorrectCredentialsException
+     * @see ExcessiveAttemptsException
+     * @see LockedAccountException
+     * @see ConcurrentAccessException
+     * @see UnknownAccountException
+     * @since 2.0
+     */
+    public org.apache.shiro.account.Account authenticateAccount(AuthenticationToken authenticationToken) throws AuthenticationException;
 }

Added: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/CompositeAccount.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/CompositeAccount.java?rev=1599014&view=auto
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/CompositeAccount.java (added)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/CompositeAccount.java Sun Jun  1 17:33:31 2014
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.shiro.authc;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @since 2.0
+ */
+public interface CompositeAccount extends org.apache.shiro.account.Account {
+
+    Set<String> getRealmNames();
+
+    void appendRealmAccount(String realmName, org.apache.shiro.account.Account account);
+
+    Map<String,Object> getRealmAttributes(String realmName);
+}

Added: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/CompositeAccountId.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/CompositeAccountId.java?rev=1599014&view=auto
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/CompositeAccountId.java (added)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/CompositeAccountId.java Sun Jun  1 17:33:31 2014
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.shiro.authc;
+
+import org.apache.shiro.account.AccountId;
+
+/**
+ * @since 2.0
+ */
+public interface CompositeAccountId extends AccountId {
+
+    AccountId getRealmAccountId(String realmName);
+}

Added: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultAuthenticator.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultAuthenticator.java?rev=1599014&view=auto
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultAuthenticator.java (added)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultAuthenticator.java Sun Jun  1 17:33:31 2014
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.shiro.authc;
+
+import org.apache.shiro.account.Account;
+import org.apache.shiro.authc.pam.UnsupportedTokenException;
+import org.apache.shiro.authc.strategy.AuthenticationStrategy;
+import org.apache.shiro.authc.strategy.DefaultAuthenticationAttempt;
+import org.apache.shiro.authc.strategy.FirstRealmSuccessfulStrategy;
+import org.apache.shiro.event.EventBus;
+import org.apache.shiro.event.EventBusAware;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.util.Assert;
+import org.apache.shiro.util.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @since 2.0
+ */
+public class DefaultAuthenticator implements Authenticator, EventBusAware {
+
+    private static final Logger log = LoggerFactory.getLogger(DefaultAuthenticator.class);
+
+    private Collection<Realm> realms;
+
+    private EventBus eventBus;
+
+    private AuthenticationStrategy authenticationStrategy;
+
+    public DefaultAuthenticator(){
+        //default in Shiro 2.0 is 'first successful'. This is the desired behavior for most Shiro users (80/20 rule).
+        // < 2.0 was 'at least one successful', which was often not desired and caused unnecessary I/O.
+        this.authenticationStrategy = new FirstRealmSuccessfulStrategy();
+    }
+
+    public Collection<Realm> getRealms() {
+        return realms;
+    }
+
+    public void setRealms(Collection<Realm> realms) {
+        this.realms = realms;
+    }
+
+    public EventBus getEventBus() {
+        return eventBus;
+    }
+
+    public void setEventBus(EventBus eventBus) {
+        this.eventBus = eventBus;
+    }
+
+    public AuthenticationStrategy getAuthenticationStrategy() {
+        return authenticationStrategy;
+    }
+
+    public void setAuthenticationStrategy(AuthenticationStrategy authenticationStrategy) {
+        this.authenticationStrategy = authenticationStrategy;
+    }
+
+    @Deprecated
+    public final AuthenticationInfo authenticate(AuthenticationToken token) throws AuthenticationException {
+        throw new UnsupportedOperationException("The " + getClass().getName() + " implementation does not support " +
+                "legacy (pre 2.0) authentication behavior.  Invoke 'authenticateAccount' instead.");
+    }
+
+    protected Account authenticateSingleRealmAccount(Realm realm, AuthenticationToken token) throws Throwable {
+        if (!realm.supports(token)) {
+            String msg = "Realm [" + realm + "] does not support authentication token [" +
+                    token + "].  Please ensure that the appropriate Realm implementation is " +
+                    "configured correctly or that the realm accepts AuthenticationTokens of this type.";
+            throw new UnsupportedTokenException(msg);
+        }
+        return realm.authenticateAccount(token);
+    }
+
+    protected Account authenticateMultiRealmAccount(Collection<Realm> realms, AuthenticationToken token) throws Throwable {
+        DefaultAuthenticationAttempt attempt =
+                new DefaultAuthenticationAttempt(token, Collections.unmodifiableCollection(realms));
+        return getAuthenticationStrategy().execute(attempt);
+    }
+
+    public Account authenticateAccount(AuthenticationToken token) throws AuthenticationException {
+
+        Assert.notNull(token, "AuthenticationToken argument cannot be null.");
+
+        log.trace("Authentication submission received for authentication token [{}]", token);
+
+        Account account;
+        try {
+            account = doAuthenticateAccount(token);
+            if (account == null) {
+                String msg = "No account returned by any configured realms for submitted authentication token ["
+                        + token + "].";
+                throw new UnknownAccountException(msg);
+            }
+        } catch (Throwable t) {
+            AuthenticationException ae = null;
+            if (t instanceof AuthenticationException) {
+                ae = (AuthenticationException) t;
+            }
+            if (ae == null) {
+                //Exception thrown was not an expected AuthenticationException.  Therefore it is probably a little more
+                //severe or unexpected.  So, wrap in an AuthenticationException, log to warn, and propagate:
+                String msg = "Authentication failed for submitted token [" + token + "].  Possible unexpected " +
+                        "error? (Typical or expected login exceptions should extend from AuthenticationException).";
+                ae = new AuthenticationException(msg, t);
+            }
+            try {
+                notifyFailure(token, ae);
+            } catch (Throwable t2) {
+                if (log.isWarnEnabled()) {
+                    String msg = "Unable to send notification for failed authentication attempt - listener error?.  " +
+                            "Please check your EventBus implementation.  Logging 'send' exception " +
+                            "and propagating original AuthenticationException instead...";
+                    log.warn(msg, t2);
+                }
+            }
+
+            throw ae;
+        }
+
+        log.debug("Authentication successful for submitted authentication token [{}].  Returned account [{}]",
+                token, account);
+
+        notifySuccess(token, account);
+
+        return account;
+    }
+
+    protected Account doAuthenticateAccount(AuthenticationToken token) throws Throwable {
+        Collection<Realm> realms = getRealms();
+        int size = CollectionUtils.size(realms);
+        Assert.isTrue(size > 0, "One or more realms must be configured to perform authentication.");
+
+        if (size == 1) {
+            return authenticateSingleRealmAccount(realms.iterator().next(), token);
+        }
+        return authenticateMultiRealmAccount(realms, token);
+    }
+
+    protected void notifySuccess(AuthenticationToken token, Account account) {
+        EventBus eventBus = getEventBus();
+        if (eventBus != null) {
+            SuccessfulAuthenticationEvent event = new SuccessfulAuthenticationEvent(this, token, account);
+            eventBus.publish(event);
+        }
+    }
+
+    protected void notifyFailure(AuthenticationToken token, Throwable t) {
+        EventBus eventBus = getEventBus();
+        if (eventBus != null) {
+            FailedAuthenticationEvent event = new FailedAuthenticationEvent(this, token, t);
+            eventBus.publish(event);
+        }
+    }
+}

Added: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultCompositeAccount.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultCompositeAccount.java?rev=1599014&view=auto
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultCompositeAccount.java (added)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultCompositeAccount.java Sun Jun  1 17:33:31 2014
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.shiro.authc;
+
+import org.apache.shiro.account.AccountId;
+import org.apache.shiro.util.CollectionUtils;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @since 2.0
+ */
+public class DefaultCompositeAccount implements CompositeAccount {
+
+    // realm name - to - attributes from that realm
+    private final Map<String, Map<String, Object>> REALM_ATTRS = new LinkedHashMap<String, Map<String, Object>>();
+
+    private final Map<String, Object> MERGED_ATTRS = new LinkedHashMap<String, Object>();
+
+    private final DefaultCompositeAccountId id;
+
+    private final boolean overwrite;
+
+    public DefaultCompositeAccount() {
+        this(true);
+    }
+
+    public DefaultCompositeAccount(boolean overwrite) {
+        this.overwrite = overwrite;
+        this.id = new DefaultCompositeAccountId();
+    }
+
+    public AccountId getId() {
+        return this.id;
+    }
+
+    public Object getCredentials() {
+        //not needed: all accounts added to a composite have already been authenticated
+        return null;
+    }
+
+    public Map<String, Object> getAttributes() {
+        return Collections.unmodifiableMap(MERGED_ATTRS);
+    }
+
+    public Set<String> getRealmNames() {
+        return Collections.unmodifiableSet(REALM_ATTRS.keySet());
+    }
+
+    public void appendRealmAccount(String realmName, org.apache.shiro.account.Account account) {
+
+        this.id.setRealmAccountId(realmName, account.getId());
+
+        Map<String, Object> realmAttributes = account.getAttributes();
+        if (realmAttributes == null) {
+            realmAttributes = Collections.emptyMap();
+        }
+
+        REALM_ATTRS.put(realmName, realmAttributes);
+
+        for (String key : realmAttributes.keySet()) {
+            if (overwrite) {
+                MERGED_ATTRS.put(key, realmAttributes.get(key));
+            } else {
+                if (!MERGED_ATTRS.containsKey(key)) {
+                    MERGED_ATTRS.put(key, realmAttributes.get(key));
+                }
+            }
+        }
+    }
+
+    public Map<String, Object> getRealmAttributes(String realmName) {
+        Map<String, Object> attrs = REALM_ATTRS.get(realmName);
+        if (CollectionUtils.isEmpty(attrs)) {
+            return Collections.emptyMap();
+        }
+        return Collections.unmodifiableMap(attrs);
+    }
+}

Added: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultCompositeAccountId.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultCompositeAccountId.java?rev=1599014&view=auto
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultCompositeAccountId.java (added)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/DefaultCompositeAccountId.java Sun Jun  1 17:33:31 2014
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.shiro.authc;
+
+import org.apache.shiro.account.AccountId;
+import org.apache.shiro.util.Assert;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * @since 2.0
+ */
+public class DefaultCompositeAccountId implements CompositeAccountId {
+
+    private Map<String,AccountId> REALM_ACCOUNTIDS = new LinkedHashMap<String,AccountId>();
+
+    public AccountId getRealmAccountId(String realmName) {
+        return realmName != null ? REALM_ACCOUNTIDS.get(realmName) : null;
+    }
+
+    public void setRealmAccountId(String realmName, AccountId accountId) {
+        Assert.hasText(realmName, "realmName must have text.");
+        Assert.notNull(accountId, "accountId cannot be null.");
+        REALM_ACCOUNTIDS.put(realmName, accountId);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == this) {
+            return true;
+        }
+        if (o instanceof DefaultCompositeAccountId) {
+            DefaultCompositeAccountId impl = (DefaultCompositeAccountId)o;
+            return REALM_ACCOUNTIDS.equals(impl.REALM_ACCOUNTIDS);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return REALM_ACCOUNTIDS.isEmpty() ? 0 : REALM_ACCOUNTIDS.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        if (REALM_ACCOUNTIDS.isEmpty()) {
+            return "";
+        }
+        StringBuilder sb = new StringBuilder();
+        for(String realmName : REALM_ACCOUNTIDS.keySet()) {
+            if (sb.length() > 0) {
+                sb.append(", ");
+            }
+            sb.append(realmName).append(": ").append(REALM_ACCOUNTIDS.get(realmName));
+        }
+        return sb.toString();
+    }
+}

Added: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/FailedAuthenticationEvent.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/FailedAuthenticationEvent.java?rev=1599014&view=auto
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/FailedAuthenticationEvent.java (added)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/FailedAuthenticationEvent.java Sun Jun  1 17:33:31 2014
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.shiro.authc;
+
+/**
+ * @since 2.0
+ */
+public class FailedAuthenticationEvent extends AuthenticationEvent {
+
+    final Throwable throwable;
+
+    public FailedAuthenticationEvent(Object source, AuthenticationToken token, Throwable throwable) {
+        super(source, token);
+        this.throwable = throwable;
+    }
+
+    public Throwable getThrowable() {
+        return throwable;
+    }
+}

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/MergableAuthenticationInfo.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/MergableAuthenticationInfo.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/MergableAuthenticationInfo.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/MergableAuthenticationInfo.java Sun Jun  1 17:33:31 2014
@@ -31,7 +31,9 @@ package org.apache.shiro.authc;
  * realm/data source.
  *
  * @since 0.9
+ * @deprecated since 2.0 in favor of {@link CompositeAccount}
  */
+@Deprecated
 public interface MergableAuthenticationInfo extends AuthenticationInfo {
 
     /**

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SaltedAuthenticationInfo.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SaltedAuthenticationInfo.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SaltedAuthenticationInfo.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SaltedAuthenticationInfo.java Sun Jun  1 17:33:31 2014
@@ -36,7 +36,9 @@ import org.apache.shiro.util.ByteSource;
  * @see org.apache.shiro.authc.credential.HashedCredentialsMatcher
  *
  * @since 1.1
+ * @deprecated since 2.0 in favor of using a {@link org.apache.shiro.authc.credential.PasswordMatcher}
  */
+@Deprecated
 public interface SaltedAuthenticationInfo extends AuthenticationInfo {
 
     /**

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SimpleAccount.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SimpleAccount.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SimpleAccount.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SimpleAccount.java Sun Jun  1 17:33:31 2014
@@ -28,19 +28,20 @@ import java.io.Serializable;
 import java.util.Collection;
 import java.util.Set;
 
-
 /**
  * Simple implementation of the {@link org.apache.shiro.authc.Account} interface that
  * contains principal and credential and authorization information (roles and permissions) as instance variables and
  * exposes them via getters and setters using standard JavaBean notation.
  *
  * @since 0.1
+ * @deprecated since 2.0 in favor of an {@link org.apache.shiro.account.Account Account} implementation.
  */
+@Deprecated
 public class SimpleAccount implements Account, MergableAuthenticationInfo, SaltedAuthenticationInfo, Serializable {
 
     /*--------------------------------------------
-    |    I N S T A N C E   V A R I A B L E S    |
-    ============================================*/
+     |    I N S T A N C E   V A R I A B L E S    |
+     ============================================*/
     /**
      * The authentication information (principals and credentials) for this account.
      */

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SimpleAuthenticationInfo.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SimpleAuthenticationInfo.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SimpleAuthenticationInfo.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SimpleAuthenticationInfo.java Sun Jun  1 17:33:31 2014
@@ -34,7 +34,9 @@ import java.util.Set;
  *
  * @see org.apache.shiro.realm.AuthenticatingRealm
  * @since 0.9
+ * @deprecated since 2.0 in favor of an {@link org.apache.shiro.account.Account Account} implementation.
  */
+@Deprecated
 public class SimpleAuthenticationInfo implements MergableAuthenticationInfo, SaltedAuthenticationInfo {
 
     /**

Added: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SuccessfulAuthenticationEvent.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SuccessfulAuthenticationEvent.java?rev=1599014&view=auto
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SuccessfulAuthenticationEvent.java (added)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/SuccessfulAuthenticationEvent.java Sun Jun  1 17:33:31 2014
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.shiro.authc;
+
+import org.apache.shiro.account.Account;
+
+/**
+ * @since 2.0
+ */
+public class SuccessfulAuthenticationEvent extends AuthenticationEvent {
+
+    final org.apache.shiro.account.Account account;
+
+    public SuccessfulAuthenticationEvent(Object source, AuthenticationToken token, org.apache.shiro.account.Account account) {
+        super(source, token);
+        this.account = account;
+    }
+
+    public Account getAccount() {
+        return account;
+    }
+}

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcher.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcher.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcher.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcher.java Sun Jun  1 17:33:31 2014
@@ -18,26 +18,50 @@
  */
 package org.apache.shiro.authc.credential;
 
+import org.apache.shiro.account.Account;
 import org.apache.shiro.authc.AuthenticationInfo;
 import org.apache.shiro.authc.AuthenticationToken;
 
 /**
  * A credentials matcher that always returns {@code true} when matching credentials no matter what arguments
- * are passed in.  This can be used for testing or when credentials are implicitly trusted for a particular
- * {@link org.apache.shiro.realm.Realm Realm}.
+ * are passed in. Configuring this matcher on a Realm effectively disables the Realm from performing any credentials
+ * comparisons itself.
+ * <p/>
+ * While this might sound unintuitive ("why would you disable the realm from asserting correct credentials?"), this
+ * matcher can be useful when the Realm does not do the credentials matching directly, but instead lets an underlying
+ * {@link org.apache.shiro.account.AccountStore AccountStore} do the credentials checking directly.
+ * <p/>
+ * This is common for example, in LDAP or ActiveDirectory scenarios: if you query LDAP for the account record using
+ * the credentials submitted in the {@code AuthenticationToken}, the LDAP server will automatically authenticate the
+ * query request before returning the account record.  In this (and similar) authenticated request scenarios, there is
+ * no further authentication for the Realm to perform itself, so it can use this {@code AllowAllCredentialsMatcher},
+ * effectively trusting the underlying account store to do the authentication work.
  *
  * @since 0.2
  */
 public class AllowAllCredentialsMatcher implements CredentialsMatcher {
 
     /**
-     * Returns <code>true</code> <em>always</em> no matter what the method arguments are.
+     * Returns {@code true} <em>always</em>, ignoring the method arguments.
      *
-     * @param token   the token submitted for authentication.
-     * @param info    the account being verified for access
-     * @return <code>true</code> <em>always</em>.
+     * @param token the token submitted for authentication.
+     * @param info  the account being verified for access
+     * @return {@code true} <em>always</em>, ignoring the method arguments.
+     * @deprecated in favor of {@link #credentialsMatch(org.apache.shiro.authc.AuthenticationToken, org.apache.shiro.account.Account)}
      */
+    @Deprecated
     public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
         return true;
     }
+
+    /**
+     * Returns {@code true} <em>always</em>, ignoring the method arguments.
+     *
+     * @param token   ignored
+     * @param account ignored
+     * @return {@code true} <em>always</em>, ignoring the method arguments.
+     */
+    public boolean credentialsMatch(AuthenticationToken token, Account account) {
+        return true;
+    }
 }

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/CredentialsMatcher.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/CredentialsMatcher.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/CredentialsMatcher.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/CredentialsMatcher.java Sun Jun  1 17:33:31 2014
@@ -18,6 +18,7 @@
  */
 package org.apache.shiro.authc.credential;
 
+import org.apache.shiro.account.Account;
 import org.apache.shiro.authc.AuthenticationInfo;
 import org.apache.shiro.authc.AuthenticationToken;
 
@@ -25,17 +26,15 @@ import org.apache.shiro.authc.Authentica
 /**
  * Interface implemented by classes that can determine if an AuthenticationToken's provided
  * credentials matches a corresponding account's credentials stored in the system.
- *
+ * <p/>
  * <p>Simple direct comparisons are handled well by the
  * {@link SimpleCredentialsMatcher SimpleCredentialsMatcher}.  If you
- * hash user's credentials before storing them in a realm (a common practice), look at the
- * {@link HashedCredentialsMatcher HashedCredentialsMatcher} implementations,
- * as they support this scenario.
+ * hash user's credentials (passwords) before storing them in a realm (a common practice), look at the
+ * {@link PasswordMatcher PasswordMatcher}.
  *
+ * @see PasswordMatcher
  * @see SimpleCredentialsMatcher
  * @see AllowAllCredentialsMatcher
- * @see Md5CredentialsMatcher
- * @see Sha1CredentialsMatcher
  * @since 0.1
  */
 public interface CredentialsMatcher {
@@ -44,11 +43,25 @@ public interface CredentialsMatcher {
      * Returns {@code true} if the provided token credentials match the stored account credentials,
      * {@code false} otherwise.
      *
-     * @param token   the {@code AuthenticationToken} submitted during the authentication attempt
-     * @param info the {@code AuthenticationInfo} stored in the system.
+     * @param token the {@code AuthenticationToken} submitted during the authentication attempt
+     * @param info  the {@code AuthenticationInfo} stored in the system.
      * @return {@code true} if the provided token credentials match the stored account credentials,
      *         {@code false} otherwise.
+     * @deprecated since 2.0 in favor of {@link #credentialsMatch(org.apache.shiro.authc.AuthenticationToken, org.apache.shiro.account.Account)}
      */
+    @Deprecated
     boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info);
 
+    /**
+     * Returns {@code true} if the provided token credentials match the stored account credentials,
+     * {@code false} otherwise.
+     *
+     * @param token   the {@code AuthenticationToken} submitted during the authentication attempt
+     * @param account the stored {@code Account} found based on the submitted token
+     *                {@link org.apache.shiro.authc.AuthenticationToken#getPrincipal() principal}.
+     * @return {@code true} if the provided token credentials match the stored account credentials,
+     *         {@code false} otherwise.
+     */
+    boolean credentialsMatch(AuthenticationToken token, Account account);
+
 }
\ No newline at end of file

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/DefaultPasswordService.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/DefaultPasswordService.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/DefaultPasswordService.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/DefaultPasswordService.java Sun Jun  1 17:33:31 2014
@@ -22,17 +22,19 @@ import org.apache.shiro.crypto.hash.Defa
 import org.apache.shiro.crypto.hash.Hash;
 import org.apache.shiro.crypto.hash.HashRequest;
 import org.apache.shiro.crypto.hash.HashService;
-import org.apache.shiro.crypto.hash.format.*;
+import org.apache.shiro.crypto.hash.format.DefaultHashFormatFactory;
+import org.apache.shiro.crypto.hash.format.HashFormat;
+import org.apache.shiro.crypto.hash.format.HashFormatFactory;
+import org.apache.shiro.crypto.hash.format.ParsableHashFormat;
+import org.apache.shiro.crypto.hash.format.Shiro1CryptFormat;
 import org.apache.shiro.util.ByteSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Default implementation of the {@link PasswordService} interface that relies on an internal
- * {@link HashService}, {@link HashFormat}, and {@link HashFormatFactory} to function:
- * <h2>Hashing Passwords</h2>
- *
- * <h2>Comparing Passwords</h2>
+ * {@link HashService}, {@link HashFormat}, and {@link HashFormatFactory} to function.
+ * <p/>
  * All hashing operations are performed by the internal {@link #getHashService() hashService}.  After the hash
  * is computed, it is formatted into a String value via the internal {@link #getHashFormat() hashFormat}.
  *

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/HashedCredentialsMatcher.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/HashedCredentialsMatcher.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/HashedCredentialsMatcher.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/HashedCredentialsMatcher.java Sun Jun  1 17:33:31 2014
@@ -18,6 +18,7 @@
  */
 package org.apache.shiro.authc.credential;
 
+import org.apache.shiro.account.Account;
 import org.apache.shiro.authc.AuthenticationInfo;
 import org.apache.shiro.authc.AuthenticationToken;
 import org.apache.shiro.authc.SaltedAuthenticationInfo;
@@ -116,7 +117,9 @@ import org.apache.shiro.util.StringUtils
  * @see org.apache.shiro.crypto.hash.Sha1Hash
  * @see org.apache.shiro.crypto.hash.Sha256Hash
  * @since 0.9
+ * @deprecated since 2.0 in favor of {@link PasswordMatcher} or implementing {@link CredentialsMatcher} directly.
  */
+@Deprecated
 public class HashedCredentialsMatcher extends SimpleCredentialsMatcher {
 
     /**
@@ -381,6 +384,16 @@ public class HashedCredentialsMatcher ex
         return equals(tokenHashedCredentials, accountCredentials);
     }
 
+    @Override
+    public boolean credentialsMatch(AuthenticationToken token, Account account) {
+        throw new UnsupportedOperationException("In Shiro 2.0, the " + HashedCredentialsMatcher.class.getName() +
+                " is deprecated.  Password comparisons should performed by a PasswordMatcher or by implementing " +
+                "the " + CredentialsMatcher.class.getName() + " interface directly.");
+        //Object tokenHashedCredentials = hashProvidedCredentials(token, account);
+        //Object accountCredentials = getCredentials(account);
+        //return equals(tokenHashedCredentials, accountCredentials);
+    }
+
     /**
      * Hash the provided {@code token}'s credentials using the salt stored with the account if the
      * {@code info} instance is an {@code instanceof} {@link SaltedAuthenticationInfo SaltedAuthenticationInfo} (see
@@ -455,5 +468,4 @@ public class HashedCredentialsMatcher ex
         String hashAlgorithmName = assertHashAlgorithmName();
         return new SimpleHash(hashAlgorithmName);
     }
-
 }

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Md2CredentialsMatcher.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Md2CredentialsMatcher.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Md2CredentialsMatcher.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Md2CredentialsMatcher.java Sun Jun  1 17:33:31 2014
@@ -18,8 +18,6 @@
  */
 package org.apache.shiro.authc.credential;
 
-import org.apache.shiro.crypto.hash.AbstractHash;
-import org.apache.shiro.crypto.hash.Hash;
 import org.apache.shiro.crypto.hash.Md2Hash;
 
 
@@ -34,8 +32,7 @@ import org.apache.shiro.crypto.hash.Md2H
  * supporting <code>CredentialsMatcher</code> implementations.</p>
  *
  * @since 0.9
- * @deprecated since 1.1 - use the HashedCredentialsMatcher directly and set its
- *             {@link HashedCredentialsMatcher#setHashAlgorithmName(String) hashAlgorithmName} property.
+ * @deprecated since 2.0 in favor of {@link PasswordMatcher} or implementing {@link CredentialsMatcher} directly.
  */
 @Deprecated
 public class Md2CredentialsMatcher extends HashedCredentialsMatcher {

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Md5CredentialsMatcher.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Md5CredentialsMatcher.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Md5CredentialsMatcher.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/Md5CredentialsMatcher.java Sun Jun  1 17:33:31 2014
@@ -18,8 +18,6 @@
  */
 package org.apache.shiro.authc.credential;
 
-import org.apache.shiro.crypto.hash.AbstractHash;
-import org.apache.shiro.crypto.hash.Hash;
 import org.apache.shiro.crypto.hash.Md5Hash;
 
 
@@ -34,9 +32,9 @@ import org.apache.shiro.crypto.hash.Md5H
  * supporting <code>CredentialsMatcher</code> implementations.</p>
  *
  * @since 0.9
- * @deprecated since 1.1 - use the HashedCredentialsMatcher directly and set its
- *             {@link HashedCredentialsMatcher#setHashAlgorithmName(String) hashAlgorithmName} property.
+ * @deprecated since 2.0 in favor of {@link PasswordMatcher} or implementing {@link CredentialsMatcher} directly.
  */
+@Deprecated
 public class Md5CredentialsMatcher extends HashedCredentialsMatcher {
 
     public Md5CredentialsMatcher() {

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/PasswordMatcher.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/PasswordMatcher.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/PasswordMatcher.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/PasswordMatcher.java Sun Jun  1 17:33:31 2014
@@ -18,6 +18,7 @@
  */
 package org.apache.shiro.authc.credential;
 
+import org.apache.shiro.account.Account;
 import org.apache.shiro.authc.AuthenticationInfo;
 import org.apache.shiro.authc.AuthenticationToken;
 import org.apache.shiro.crypto.hash.Hash;
@@ -39,6 +40,7 @@ public class PasswordMatcher implements 
         this.passwordService = new DefaultPasswordService();
     }
 
+    @Deprecated
     public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
 
         PasswordService service = ensurePasswordService();
@@ -57,6 +59,24 @@ public class PasswordMatcher implements 
         return passwordService.passwordsMatch(submittedPassword, formatted);
     }
 
+    //since 2.0
+    public boolean credentialsMatch(AuthenticationToken token, Account account) {
+        PasswordService service = ensurePasswordService();
+
+        Object submittedPassword = getSubmittedPassword(token);
+        Object storedCredentials = getStoredPassword(account);
+        assertStoredCredentialsType(storedCredentials);
+
+        if (storedCredentials instanceof Hash) {
+            Hash hashedPassword = (Hash)storedCredentials;
+            HashingPasswordService hashingService = assertHashingPasswordService(service);
+            return hashingService.passwordsMatch(submittedPassword, hashedPassword);
+        }
+        //otherwise they are a String (asserted in the 'assertStoredCredentialsType' method call above):
+        String formatted = (String)storedCredentials;
+        return passwordService.passwordsMatch(submittedPassword, formatted);
+    }
+
     private HashingPasswordService assertHashingPasswordService(PasswordService service) {
         if (service instanceof HashingPasswordService) {
             return (HashingPasswordService) service;
@@ -100,6 +120,15 @@ public class PasswordMatcher implements 
         return stored;
     }
 
+    protected Object getStoredPassword(Account account) {
+        Object stored = account != null ? account.getCredentials() : null;
+        //fix for https://issues.apache.org/jira/browse/SHIRO-363
+        if (stored instanceof char[]) {
+            stored = new String((char[])stored);
+        }
+        return stored;
+    }
+
     public PasswordService getPasswordService() {
         return passwordService;
     }

Modified: shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/PasswordService.java
URL: http://svn.apache.org/viewvc/shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/PasswordService.java?rev=1599014&r1=1599013&r2=1599014&view=diff
==============================================================================
--- shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/PasswordService.java (original)
+++ shiro/branches/2.0-api-design-changes/core/src/main/java/org/apache/shiro/authc/credential/PasswordService.java Sun Jun  1 17:33:31 2014
@@ -54,10 +54,10 @@ import org.apache.shiro.util.ByteSource;
  * <pre>
  * [main]
  * ...
- * passwordService = org.apache.shiro.authc.credential.DefaultPasswordService
+ * passwordService = {@link org.apache.shiro.authc.credential.DefaultPasswordService org.apache.shiro.authc.credential.DefaultPasswordService}
  * # configure the passwordService to use the settings you desire
  * ...
- * passwordMatcher = org.apache.shiro.authc.credential.PasswordMatcher
+ * passwordMatcher = {@link org.apache.shiro.authc.credential.PasswordMatcher org.apache.shiro.authc.credential.PasswordMatcher}
  * passwordMatcher.passwordService = $passwordService
  * ...
  * # Finally, set the matcher on a realm that requires password matching for account authentication: