// authenticate user
UserManager userManager = context.getUserManager();
User authenticatedUser = null;
try {
UserMetadata userMetadata = new UserMetadata();
if (session.getRemoteAddress() instanceof InetSocketAddress) {
userMetadata.setInetAddress(((InetSocketAddress) session
.getRemoteAddress()).getAddress());
}
userMetadata.setCertificateChain(session
.getClientCertificates());
Authentication auth;
if (anonymous) {
auth = new AnonymousAuthentication(userMetadata);