// Attempt to associate with the OpenID provider
// and retrieve one service endpoint for authentication
DiscoveryInformation discovered = manager.associate(discoveries);
// Create a memento to rebuild the discovered information in a subsequent request
DiscoveryInformationMemento memento = new DiscoveryInformationMemento();
if (discovered.getClaimedIdentifier() != null) {
memento.setClaimedIdentifier(discovered.getClaimedIdentifier().getIdentifier());
}
memento.setDelegate(discovered.getDelegateIdentifier());
if (discovered.getOPEndpoint() != null) {
memento.setOpEndpoint(discovered.getOPEndpoint().toString());
}
memento.setTypes(discovered.getTypes());
memento.setVersion(discovered.getVersion());
// Create a temporary User to preserve state between requests without
// using a session (we could be in a cluster)
User tempUser = new User(sessionToken);
tempUser.setOpenIDDiscoveryInformationMemento(memento);