no.difi.certvalidator.parser.ValidatorKeyStoresLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-certvalidator Show documentation
Show all versions of commons-certvalidator Show documentation
Rule engine for creation of certificate validator.
package no.difi.certvalidator.parser;
import no.difi.certvalidator.api.CertificateBucketException;
import no.difi.certvalidator.api.Order;
import no.difi.certvalidator.api.ValidatorRecipeParser;
import no.difi.certvalidator.jaxb.KeyStoreType;
import no.difi.certvalidator.jaxb.ValidatorRecipe;
import no.difi.certvalidator.lang.ValidatorParsingException;
import no.difi.certvalidator.util.KeyStoreCertificateBucket;
import org.kohsuke.MetaInfServices;
import java.io.ByteArrayInputStream;
import java.util.Map;
/**
* @author erlend
*/
@Order(100)
@MetaInfServices
public class ValidatorKeyStoresLoader implements ValidatorRecipeParser {
@Override
public void parse(ValidatorRecipe recipe, Map objectStorage) throws ValidatorParsingException {
try {
for (KeyStoreType keyStoreType : recipe.getKeyStore()) {
objectStorage.put(
String.format("#keyStore::%s", keyStoreType.getName() == null ? "default" : keyStoreType.getName()),
new KeyStoreCertificateBucket(
new ByteArrayInputStream(keyStoreType.getValue()),
keyStoreType.getPassword()
)
);
}
} catch (CertificateBucketException e) {
throw new ValidatorParsingException(e.getMessage(), e);
}
}
}