/** * Merges the specified <code>AuthenticationInfo</code> into this <code>Account</code>. * <p/> * If the specified argument is also an instance of {@link SimpleAccount SimpleAccount}, the * {@link #isLocked()} and {@link #isCredentialsExpired()} attributes are merged (set on this instance) as well * (only if their values are <code>true</code>). * * @param info the <code>AuthenticationInfo</code> to merge into this account. */ public void merge(AuthenticationInfo info) { authcInfo.merge(info); // Merge SimpleAccount specific info if (info instanceof SimpleAccount) { SimpleAccount otherAccount = (SimpleAccount) info; if (otherAccount.isLocked()) { setLocked(true); } if (otherAccount.isCredentialsExpired()) { setCredentialsExpired(true); } } }
@Test public void testMergeWithEmptyInstances() { SimpleAuthenticationInfo aggregate = new SimpleAuthenticationInfo(); SimpleAuthenticationInfo local = new SimpleAuthenticationInfo(); aggregate.merge(local); }
/** * Verifies fix for JSEC-122 */ @Test public void testMergeWithAggregateNullCredentials() { SimpleAuthenticationInfo aggregate = new SimpleAuthenticationInfo(); SimpleAuthenticationInfo local = new SimpleAuthenticationInfo("username", "password", "testRealm"); aggregate.merge(local); }
aggregate.setPrincipals(principalCollection); SimpleAuthenticationInfo local = new SimpleAuthenticationInfo("username", "password", "testRealm"); aggregate.merge(local); assertEquals(2, aggregate.getPrincipals().asList().size());
/** * Merges the specified <code>AuthenticationInfo</code> into this <code>Account</code>. * <p/> * If the specified argument is also an instance of {@link SimpleAccount SimpleAccount}, the * {@link #isLocked()} and {@link #isCredentialsExpired()} attributes are merged (set on this instance) as well * (only if their values are <code>true</code>). * * @param info the <code>AuthenticationInfo</code> to merge into this account. */ public void merge(AuthenticationInfo info) { authcInfo.merge(info); // Merge SimpleAccount specific info if (info instanceof SimpleAccount) { SimpleAccount otherAccount = (SimpleAccount) info; if (otherAccount.isLocked()) { setLocked(true); } if (otherAccount.isCredentialsExpired()) { setCredentialsExpired(true); } } }
/** * Merges the specified <code>AuthenticationInfo</code> into this <code>Account</code>. * <p/> * If the specified argument is also an instance of {@link SimpleAccount SimpleAccount}, the * {@link #isLocked()} and {@link #isCredentialsExpired()} attributes are merged (set on this instance) as well * (only if their values are <code>true</code>). * * @param info the <code>AuthenticationInfo</code> to merge into this account. */ public void merge(AuthenticationInfo info) { authcInfo.merge(info); // Merge SimpleAccount specific info if (info instanceof SimpleAccount) { SimpleAccount otherAccount = (SimpleAccount) info; if (otherAccount.isLocked()) { setLocked(true); } if (otherAccount.isCredentialsExpired()) { setCredentialsExpired(true); } } }
@Override public void merge( AuthenticationInfo info ) { if ( info == null || info.getPrincipals() == null || info.getPrincipals().isEmpty() ) { return; } super.merge( info ); if ( info instanceof ShiroAuthenticationInfo ) { authenticationResult = mergeAuthenticationResult( authenticationResult, ((ShiroAuthenticationInfo) info).getAuthenticationResult() ); } else { // If we get here (which means no AuthenticationException or UnknownAccountException was thrown) // it means the realm that provided the info was able to authenticate the subject, // so we claim the result to be an implicit success authenticationResult = mergeAuthenticationResult( authenticationResult, AuthenticationResult.SUCCESS ); } }