class HubEidasAttributeQueryRequestToSamlAttributeQueryTransformer implements Function<HubEidasAttributeQueryRequest,AttributeQuery> {

    public AttributeQuery apply(HubEidasAttributeQueryRequest originalQuery) {
        AttributeQuery transformedQuery = samlObjectFactory.createAttributeQuery();

        Issuer issuer = samlObjectFactory.createIssuer(originalQuery.getIssuer());

        transformedQuery.setID(originalQuery.getId());
        transformedQuery.setIssuer(issuer);
        transformedQuery.setIssueInstant(DateTime.now());

        if (originalQuery.getUserAccountCreationAttributes().isPresent()){
            transformedQuery.getAttributes().addAll(createAttributeList(originalQuery.getUserAccountCreationAttributes().get()));
        }

        Subject subject = samlObjectFactory.createSubject();
        NameID nameId = samlObjectFactory.createNameId(originalQuery.getPersistentId().getNameId());
        nameId.setSPNameQualifier(originalQuery.getAuthnRequestIssuerEntityId());
        nameId.setNameQualifier(originalQuery.getAssertionConsumerServiceUrl().toASCIIString());
        subject.setNameID(nameId);

        SubjectConfirmation subjectConfirmation = samlObjectFactory.createSubjectConfirmation();
        SubjectConfirmationData subjectConfirmationData = samlObjectFactory.createSubjectConfirmationData();

        final Optional<HubAssertion> cycle3DatasetAssertion = originalQuery.getCycle3AttributeAssertion();
        if (cycle3DatasetAssertion.isPresent()) {
            Assertion transformedCycle3DatasetAssertion = hubAssertionMarshaller.toSaml(cycle3DatasetAssertion.get());
            subjectConfirmationData.getUnknownXMLObjects(Assertion.DEFAULT_ELEMENT_NAME).add(transformedCycle3DatasetAssertion);
        }

        subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);
        subject.getSubjectConfirmations().add(subjectConfirmation);

        transformedQuery.setSubject(subject);

        Optional<CountrySignedResponseContainer> countrySignedResponseContainer = originalQuery.getCountrySignedResponseContainer();
        if (countrySignedResponseContainer.isPresent()) {
            Assertion unsignedAssertion = eidasUnsignedAssertionsTransformer.transform(originalQuery);
            subjectConfirmationData.getUnknownXMLObjects(Assertion.DEFAULT_ELEMENT_NAME).add(unsignedAssertion);
        } else {
            final String encryptedIdentityAssertion = originalQuery.getEncryptedIdentityAssertion();
            EncryptedAssertion encryptedAssertion = encryptedAssertionUnmarshaller.transform(encryptedIdentityAssertion);
            subjectConfirmationData.getUnknownXMLObjects(EncryptedAssertion.DEFAULT_ELEMENT_NAME).add(encryptedAssertion);
        }
        return transformedQuery;
    }

    public  HubEidasAttributeQueryRequestToSamlAttributeQueryTransformer(
            final OpenSamlXmlObjectFactory samlObjectFactory,
            final HubAssertionMarshaller hubAssertionMarshaller,
            final AssertionFromIdpToAssertionTransformer assertionFromIdpTransformer,
            final AttributeQueryAttributeFactory attributeQueryAttributeFactory,
            final EncryptedAssertionUnmarshaller encryptedAssertionUnmarshaller,
            EidasUnsignedAssertionsTransformer eidasUnsignedAssertionsTransformer);

}