private Object handleAuthenticated() { if (isOwnerConnection()) { final String uuid = getUuid(); final String localMemberUUID = clientEngine.getLocalMember().getUuid(); principal = new ClientPrincipal(uuid, localMemberUUID); reAuthLocal(); Collection<Member> members = nodeEngine.getClusterService().getMembers(); for (Member member : members) { if (!member.localMember()) { ClientReAuthOperation op = new ClientReAuthOperation(uuid); op.setCallerUuid(localMemberUUID); nodeEngine.getOperationService().send(op, member.getAddress()); } } } boolean isNotMember = clientEngine.getClusterService().getMember(principal.getOwnerUuid()) == null; if (isNotMember) { throw new AuthenticationException( "Invalid owner-uuid: " + principal.getOwnerUuid() + ", it's not member of this cluster!"); } endpoint.authenticated(principal, credentials, isOwnerConnection()); setConnectionType(); endpointManager.registerEndpoint(endpoint); clientEngine.bind(endpoint); final Address thisAddress = clientEngine.getThisAddress(); return encodeAuth(thisAddress, principal.getUuid(), principal.getOwnerUuid()); }
@Override public String getUuid() { final ClientPrincipal cp = principal; return cp != null ? cp.getUuid() : null; }
private void reAuthLocal() { final Set<ClientEndpoint> endpoints = endpointManager.getEndpoints(principal.getUuid()); for (ClientEndpoint endpoint : endpoints) { endpoint.authenticated(principal); } }
private String getUuid() { if (principal != null) { return principal.getUuid(); } return UuidUtil.createClientUuid(endpoint.getConnection().getEndPoint()); }