forked from apereo/cas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a013bb8
commit 3a7a161
Showing
37 changed files
with
292 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 46 additions & 4 deletions
50
...-authentication/src/main/java/org/jasig/cas/authentication/AuthenticationTransaction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,61 @@ | ||
package org.jasig.cas.authentication; | ||
|
||
import java.io.Serializable; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Iterator; | ||
import java.util.Set; | ||
|
||
/** | ||
* This is {@link AuthenticationTransaction}. | ||
* | ||
* @author Misagh Moayyed | ||
* @since 4.2.0 | ||
*/ | ||
public interface AuthenticationTransaction { | ||
public final class AuthenticationTransaction implements Serializable { | ||
|
||
private static final long serialVersionUID = 6213904009424725484L; | ||
|
||
private final Collection<Credential> credentials; | ||
|
||
/** | ||
* Gets credentials. | ||
* Instantiates a new Default authentication transaction. | ||
* | ||
* @return the credentials | ||
* @param credentials the credentials | ||
*/ | ||
Collection<Credential> getCredentials(); | ||
private AuthenticationTransaction(final Collection<Credential> credentials) { | ||
this.credentials = credentials; | ||
} | ||
|
||
public Collection<Credential> getCredentials() { | ||
return this.credentials; | ||
} | ||
|
||
/** | ||
* Wrap credentials into an authentication transaction, as a factory method, | ||
* and return the final result. | ||
* | ||
* @param credentials the credentials | ||
* @return the authentication transaction | ||
*/ | ||
public static AuthenticationTransaction wrap(final Credential... credentials) { | ||
return new AuthenticationTransaction(sanitizeCredentials(credentials)); | ||
} | ||
|
||
private static Set<Credential> sanitizeCredentials(final Credential[] credentials) { | ||
if (credentials != null && credentials.length > 0) { | ||
final Set<Credential> set = new HashSet<>(Arrays.asList(credentials)); | ||
final Iterator<Credential> it = set.iterator(); | ||
while (it.hasNext()) { | ||
if (it.next() == null) { | ||
it.remove(); | ||
} | ||
} | ||
return set; | ||
} | ||
return Collections.emptySet(); | ||
} | ||
} | ||
|
17 changes: 0 additions & 17 deletions
17
...tication/src/main/java/org/jasig/cas/authentication/AuthenticationTransactionFactory.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
...tication/src/main/java/org/jasig/cas/authentication/DefaultAuthenticationTransaction.java
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
...n/src/main/java/org/jasig/cas/authentication/DefaultAuthenticationTransactionFactory.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.