/** * Computes participant ID using optional {@link ParamsProperty.PROXYING_FOR} * parameter. * * @param operation the operation to be executed. * @param participant the base participant id. * @return new participant instance in the format * somebody+proxyFor@example.com. If proxyFor is null then just * returns unmodified participant. * @throws InvalidRequestException if participant address and/or proxyFor are * invalid. */ public static ParticipantId computeParticipant(OperationRequest operation, ParticipantId participant) throws InvalidRequestException { String proxyAddress = OperationUtil.getOptionalParameter(operation, ParamsProperty.PROXYING_FOR); try { return toProxyParticipant(participant, proxyAddress); } catch (InvalidParticipantAddress e) { throw new InvalidRequestException( participant.getAddress() + (proxyAddress != null ? "+" + proxyAddress : "" + " is not a valid participant address"), operation); } }
public void testToProxyParticipant() throws Exception { ParticipantId participant = ParticipantId.of("foo@example.com"); ParticipantId proxyParticipant = ParticipantId.of("foo+proxyFor@example.com"); assertEquals(proxyParticipant, OperationUtil.toProxyParticipant(participant, "proxyFor")); // If participant is already a proxy - return without a change. assertEquals(proxyParticipant, OperationUtil.toProxyParticipant(proxyParticipant, "proxyFor")); }
public void testToProxyParticipant() throws Exception { ParticipantId participant = ParticipantId.of("foo@example.com"); ParticipantId proxyParticipant = ParticipantId.of("foo+proxyFor@example.com"); assertEquals(proxyParticipant, OperationUtil.toProxyParticipant(participant, "proxyFor")); // If participant is already a proxy - return without a change. assertEquals(proxyParticipant, OperationUtil.toProxyParticipant(proxyParticipant, "proxyFor")); }