Hello
For few days I'm straggling with some problem.
My applicationsContext config file looks like that:
<bean id="ksInputStream" class="java.io.FileInputStream">
<constructor-arg type="java.lang.String" value="/tmp/out.jks"></constructor-arg>
</bean>
<bean id="keyStoreProvider" class="java.security.KeyStore" factory-method="getInstance">
<constructor-arg type="java.lang.String" value="jks"></constructor-arg>
</bean>
<bean id="certVerificator" class="pki.certificate.CertVerificatorImpl" destroy-method="save" init-method="setUp">
<property name="ksIs">
<ref bean="ksInputStream"/>
</property>
<property name="keyStore">
<ref bean="keyStoreProvider"/>
</property>
<property name="ksOs">
<ref bean="ksOutputStream"/>
</property>
</bean>
So as You can see I'm injecting FileInputStream as property on certVerificator bean, here you have setter:
public void setKsIs(InputStream ksIs) throws IOException
{
this.ksIs = ksIs;
}
Everything works fine with one little problem(main method):
AbstractApplicationContext ac = new ClassPathXmlApplicationContext("cfg/testApplicationContext.xml");
CertVerificatorImpl cv = (CertVerificatorImpl)ac.getBean("certVerificator") ;
cv.preValidateCertFile("org.cert", RandomStringUtils.randomAlphanumeric(4) );
cv.preValidateCertFile("second.pem", RandomStringUtils.randomAlphanumeric(4) );
ac.close();
I'm validate certificate and storing them to KeyStore and this id fine, but when I'm trying to load stored before certs ( from FileInputStream on /tmp/out.jks ) file is EOFExeption.
When I was debugging application I observed that when application context is loaded out.jks is cleaned!! What is going on?


Reply With Quote
