Skip to content

Commit

Permalink
renamed API method to processAuthenticationAttempt
Browse files Browse the repository at this point in the history
  • Loading branch information
SavvasMisaghMoayyed committed Dec 10, 2015
1 parent 69cc8be commit 1b04b09
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public interface AuthenticationContextBuilder {
* Collect a new authenication event and store it.
*
* @param authentication the new authentication event
* @return the boolean
* @return the builder instance in a fluid manner
* @throws AuthenticationException the authentication exception
*/
boolean collect(Authentication authentication) throws AuthenticationException;
AuthenticationContextBuilder collect(Authentication authentication) throws AuthenticationException;

/**
* Build authentication context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ public interface AuthenticationTransactionManager {
* Authenticate boolean.
*
* @param credentials the credentials
* @return the context builder
* @throws AuthenticationException the authentication exception
*/
void processAuthenticationAttempt(final Credential... credentials) throws AuthenticationException;
AuthenticationContextBuilder processAuthenticationAttempt(final Credential... credentials) throws AuthenticationException;

/**
* Build authentication context authentication context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public boolean isEmpty() {
}

@Override
public boolean collect(final Authentication authentication) throws AuthenticationException {
public AuthenticationContextBuilder collect(final Authentication authentication) throws AuthenticationException {
if (this.authentications.add(authentication)) {
LOGGER.debug("Collected authentication event. Associated principal with this authentication is [{}]",
authentication.getPrincipal());
return true;
} else {
LOGGER.warn("Failed to collect duplicate authentication event as it already exists.");
}
LOGGER.warn("Failed to collect duplicate authentication event as it already exists.");
return false;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,13 @@
*/
@Component("defaultAuthenticationSupervisor")
public final class DefaultAuthenticationTransactionManager implements AuthenticationTransactionManager {
/**
* The constant LOGGER.
*/

private static final Logger LOGGER = LoggerFactory.getLogger(DefaultAuthenticationTransactionManager.class);

/**
* The Authentication manager.
*/
@Autowired
@Qualifier("authenticationManager")
private AuthenticationManager authenticationManager;

/**
* The Authentication context builder.
*/
@Autowired
@Qualifier("defaultAuthenticationContextBuilder")
private AuthenticationContextBuilder authenticationContextBuilder;
Expand All @@ -45,7 +37,7 @@ public final class DefaultAuthenticationTransactionManager implements Authentica
public DefaultAuthenticationTransactionManager() {}

@Override
public void processAuthenticationAttempt(final Credential... credentials) throws AuthenticationException {
public AuthenticationContextBuilder processAuthenticationAttempt(final Credential... credentials) throws AuthenticationException {
final Set<Credential> sanitizedCredentials = sanitizeCredentials(credentials);
if (!sanitizedCredentials.isEmpty()) {
final Credential[] sanitizedCredentialsArray = sanitizedCredentials.toArray(new Credential[] {});
Expand All @@ -57,6 +49,7 @@ public void processAuthenticationAttempt(final Credential... credentials) throws
} else {
LOGGER.debug("No credentials were provided for authentication");
}
return authenticationContextBuilder;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import static org.mockito.Mockito.*;

/**
* This is {@link DefaultAuthenticationSupervisorTests}.
* This is {@link DefaultAuthenticationTransactionManagerTests}.
*
* @author Misagh Moayyed
* @since 4.2.0
*/
public class DefaultAuthenticationSupervisorTests {
public class DefaultAuthenticationTransactionManagerTests {

private AuthenticationManager manager;
private DefaultAuthenticationContextBuilder builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public void setUp() throws Exception {

this.action.setCentralAuthenticationService(centralAuthenticationService);

final DefaultAuthenticationTransactionManager supervisor = (DefaultAuthenticationTransactionManager) getAuthenticationTransactionManager();
final DefaultAuthenticationTransactionManager supervisor =
(DefaultAuthenticationTransactionManager) getAuthenticationTransactionManager();
supervisor.setAuthenticationManager(authenticationManager);
this.action.setAuthenticationTransactionManager(supervisor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public void setUp() throws Exception {
getCentralAuthenticationService();
this.action.setCentralAuthenticationService(centralAuthenticationService);

final DefaultAuthenticationTransactionManager supervisor = (DefaultAuthenticationTransactionManager) getAuthenticationTransactionManager();
final DefaultAuthenticationTransactionManager supervisor =
(DefaultAuthenticationTransactionManager) getAuthenticationTransactionManager();
supervisor.setAuthenticationManager(authenticationManager);
this.action.setAuthenticationTransactionManager(supervisor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public void setUp() throws Exception {
getCentralAuthenticationService();

this.action.setCentralAuthenticationService(centralAuthenticationService);
final DefaultAuthenticationTransactionManager supervisor = (DefaultAuthenticationTransactionManager) getAuthenticationTransactionManager();
final DefaultAuthenticationTransactionManager supervisor =
(DefaultAuthenticationTransactionManager) getAuthenticationTransactionManager();
supervisor.setAuthenticationManager(authenticationManager);
this.action.setAuthenticationTransactionManager(supervisor);

Expand Down

0 comments on commit 1b04b09

Please sign in to comment.