/** * Get the participant id of the given subject. * * The subject is searched for compatible principals. When other * authentication types are added, this method will need to be updated to * support their principal types. * * @throws InvalidParticipantAddress The subject's address is invalid */ private ParticipantId getLoggedInUser(Subject subject) throws InvalidParticipantAddress { String address = null; for (Principal p : subject.getPrincipals()) { // TODO(josephg): When we support other authentication types (LDAP, etc), // this method will need to read the address portion out of the other principal types. if (p instanceof ParticipantPrincipal) { address = ((ParticipantPrincipal) p).getName(); break; } else if (p instanceof X500Principal) { return attemptClientCertificateLogin((X500Principal)p); } } return address == null ? null : ParticipantId.of(address); }