protected KeyDescriptor getKeyDescriptor(final UsageType type, final KeyInfo key) {
        val builder = (SAMLObjectBuilder<KeyDescriptor>)
            Configuration.getBuilderFactory()
                .getBuilder(KeyDescriptor.DEFAULT_ELEMENT_NAME);
        val descriptor = Objects.requireNonNull(builder).buildObject();
        descriptor.setUse(type);
        descriptor.setKeyInfo(key);
        return descriptor;
    }
<p>getKeyDescriptor.</p>

@param type a {@link UsageType} object
@param key  a {@link KeyInfo} object
@return a {@link KeyDescriptor} object
pac4j-saml/src/main/java/org/pac4j/saml/metadata/BaseSAML2MetadataGenerator.java