use of org.codice.ddf.security.OcspService in project ddf by codice.
the class PKIHandlerTest method getPKIHandlerWithMockedCrl.
/**
* Creates a PKIHandler with a mocked CrlChecker that always returns true or false
*
* @param returnedValue Boolean value that the mocked CrlChecker will always return
* @return A PKIHandler with a mocked CrlChecker
*/
private PKIHandler getPKIHandlerWithMockedCrl(boolean returnedValue) throws URISyntaxException {
System.setProperty(SecurityConstants.TRUSTSTORE_TYPE, "JKS");
System.setProperty(SecurityConstants.TRUSTSTORE_PATH, getClass().getResource("/serverTruststore.jks").toURI().getPath());
System.setProperty(SecurityConstants.TRUSTSTORE_PASSWORD, "changeit");
System.setProperty(SecurityConstants.TRUSTSTORE_TYPE, "JKS");
System.setProperty(SecurityConstants.TRUSTSTORE_PATH, getClass().getResource("/serverTruststore.jks").toURI().getPath());
System.setProperty(SecurityConstants.TRUSTSTORE_PASSWORD, "changeit");
PKIHandler handler = new PKIHandler();
AuthenticationTokenFactory tokenFactory = new AuthenticationTokenFactory();
handler.setTokenFactory(tokenFactory);
OcspService ocspService = mock(OcspService.class);
when(ocspService.passesOcspCheck(any())).thenReturn(returnedValue);
handler.setOcspService(ocspService);
CrlChecker crlChecker = mock(CrlChecker.class);
when(crlChecker.passesCrlCheck(any())).thenReturn(returnedValue);
handler.crlChecker = crlChecker;
return handler;
}
Aggregations