use of org.pac4j.core.util.serializer.JavaSerializer in project pac4j by pac4j.
the class RunClient method run.
public void run() {
final var client = getClient();
final var context = MockWebContext.create();
final SessionStore sessionStore = new MockSessionStore();
final var url = ((FoundAction) client.getRedirectionAction(context, sessionStore).get()).getLocation();
logger.warn("Redirect to: \n{}", url);
if (CommonHelper.isNotBlank(getLogin()) && CommonHelper.isNotBlank(getPassword())) {
logger.warn("Use credentials: {} / {}", getLogin(), getPassword());
} else {
logger.warn("Use your own personal credentials");
}
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 var scanner = new Scanner(System.in, StandardCharsets.UTF_8.name());
final var returnedUrl = scanner.nextLine().trim();
populateContextWithUrl(context, returnedUrl);
final var credentials = client.getCredentials(context, sessionStore);
if (credentials.isPresent()) {
final var profile = client.getUserProfile(credentials.get(), context, sessionStore);
logger.debug("userProfile: {}", profile);
if (profile.isPresent() || !canCancel()) {
verifyProfile((CommonProfile) profile.get());
logger.warn("## Java serialization");
final var javaSerializer = new JavaSerializer();
var bytes = javaSerializer.serializeToBytes(profile.get());
final var profile2 = (CommonProfile) javaSerializer.deserializeFromBytes(bytes);
verifyProfile(profile2);
}
}
logger.warn("################");
logger.warn("Test successful!");
}
Aggregations