use of org.pac4j.core.credentials.Credentials in project pac4j by pac4j.
the class LocalCachingAuthenticatorTests method testDoubleCalls.
@Test
public void testDoubleCalls() {
final OnlyOneCallAuthenticator authenticator = new OnlyOneCallAuthenticator();
final LocalCachingAuthenticator localCachingAuthenticator = new LocalCachingAuthenticator(authenticator, 10, 10, TimeUnit.SECONDS);
localCachingAuthenticator.init();
final Credentials credentials1 = new UsernamePasswordCredentials("a", "a");
localCachingAuthenticator.validate(credentials1, null);
final Credentials credentials2 = new UsernamePasswordCredentials("a", "a");
localCachingAuthenticator.validate(credentials2, null);
}
use of org.pac4j.core.credentials.Credentials in project pac4j by pac4j.
the class RunClient method run.
public void run() {
final IndirectClient client = getClient();
final MockWebContext context = MockWebContext.create();
final String url = client.getRedirectAction(context).getLocation();
logger.warn("Redirect to: \n{}", url);
logger.warn("Use credentials: {} / {}", getLogin(), getPassword());
if (canCancel()) {
logger.warn("You can CANCEL the authentication.");
}
logger.warn("Returned url (copy/paste the fragment starting before the question mark of the query string):");
final Scanner scanner = new Scanner(System.in, StandardCharsets.UTF_8.name());
final String returnedUrl = scanner.nextLine().trim();
populateContextWithUrl(context, returnedUrl);
final Credentials credentials = client.getCredentials(context);
final CommonProfile profile = client.getUserProfile(credentials, context);
logger.debug("userProfile: {}", profile);
if (profile != null || !canCancel()) {
verifyProfile(profile);
logger.warn("## Java serialization");
final JavaSerializationHelper javaSerializationHelper = new JavaSerializationHelper();
byte[] bytes = javaSerializationHelper.serializeToBytes(profile);
final CommonProfile profile2 = (CommonProfile) javaSerializationHelper.unserializeFromBytes(bytes);
verifyProfile(profile2);
}
logger.warn("################");
logger.warn("Test successful!");
}
Aggregations