class AttributeQueryGenerator {

    public AttributeQueryContainerDto createAttributeQueryContainer(final T attributeQueryRequest,
                                                                    final URI msaUri,
                                                                    final String matchingServiceEntityId,
                                                                    final DateTime matchingServiceRequestTimeOut,
                                                                    boolean onboarding) {

        try {
            entityToEncryptForLocator.addEntityIdForRequestId(
                    attributeQueryRequest.getId(),
                    matchingServiceEntityId);

            String samlRequest =
                    XmlUtils.writeToString(attributeQueryRequestTransformer.apply(attributeQueryRequest));
            return new AttributeQueryContainerDto(
                    attributeQueryRequest.getId(),
                    attributeQueryRequest.getIssuer(),
                    samlRequest,
                    msaUri,
                    matchingServiceRequestTimeOut,
                    onboarding);
        } finally {
            entityToEncryptForLocator.removeEntityIdForRequestId(attributeQueryRequest.getId());
        }
    }

    @Inject public  AttributeQueryGenerator(
            final Function<T, Element> attributeQueryRequestTransformer,
            final AssignableEntityToEncryptForLocator entityToEncryptForLocator);

}