Class PropertyToX509CertificateConverter
java.lang.Object
se.swedenconnect.security.credential.spring.converters.AbstractResourcePropertyConverter<X509Certificate>
se.swedenconnect.security.credential.spring.converters.PropertyToX509CertificateConverter
- All Implemented Interfaces:
Aware
,ApplicationContextAware
,Converter<String,
X509Certificate>
public class PropertyToX509CertificateConverter
extends AbstractResourcePropertyConverter<X509Certificate>
A
Converter
that gets the property value (e.g., classpath:cert.crt
) and instantiates an
X509Certificate
object. The converter also handles "inlined" PEM certificates.
To use this converter it has to be instantiated as a bean and then registered in the registry using
ConverterRegistry.addConverter(Converter)
.
If you are using Spring Boot, do:
@Bean @ConfigurationPropertiesBinding public PropertyToX509CertificateConverter propertyToX509CertificateConverter() { return new PropertyToX509CertificateConverter(); }
- Author:
- Martin Lindström (martin@idsec.se)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconvert
(InputStream inputStream) Converts the input stream to the object supported by the converter.protected boolean
isInlinedPem
(String property) Tells whether the property value holds an "inlined" PEM representation of the object.Methods inherited from class se.swedenconnect.security.credential.spring.converters.AbstractResourcePropertyConverter
convert, setApplicationContext
-
Constructor Details
-
PropertyToX509CertificateConverter
public PropertyToX509CertificateConverter()
-
-
Method Details
-
convert
@Nonnull public X509Certificate convert(@Nonnull InputStream inputStream) throws CertificateException Converts the input stream to the object supported by the converter.The stream must not be closed.
- Specified by:
convert
in classAbstractResourcePropertyConverter<X509Certificate>
- Parameters:
inputStream
- the stream- Returns:
- the object
- Throws:
CertificateException
-
isInlinedPem
Tells whether the property value holds an "inlined" PEM representation of the object.- Specified by:
isInlinedPem
in classAbstractResourcePropertyConverter<X509Certificate>
- Parameters:
property
- the property value- Returns:
true
if the property holds a PEM object, andfalse
otherwise
-