use of org.apache.jackrabbit.spi.RepositoryService in project jackrabbit by apache.
the class RepositoryStubImpl method getRepository.
@Override
public synchronized Repository getRepository() throws RepositoryStubException {
if (repository == null) {
try {
String url = environment.getProperty(PROP_REPOSITORY_URL);
final RepositoryService service = createService(url);
repository = RepositoryImpl.create(new AbstractRepositoryConfig() {
public RepositoryService getRepositoryService() {
return service;
}
});
} catch (Exception e) {
throw new RepositoryStubException(e);
}
}
return repository;
}
use of org.apache.jackrabbit.spi.RepositoryService in project jackrabbit by apache.
the class ConnectionTest method testObtainWithoutTLS.
public void testObtainWithoutTLS() throws RepositoryException, URISyntaxException {
RepositoryService repositoryService = createRepositoryService(false, null);
repositoryService.obtain(new SimpleCredentials("admin", "admin".toCharArray()), null);
}
use of org.apache.jackrabbit.spi.RepositoryService in project jackrabbit by apache.
the class ConnectionTest method testObtainWithTLSSelfSignedCertNotAllowed.
public void testObtainWithTLSSelfSignedCertNotAllowed() throws RepositoryException, URISyntaxException {
RepositoryService repositoryService = createRepositoryService(true, null);
try {
repositoryService.obtain(new SimpleCredentials("admin", "admin".toCharArray()), null);
fail("should have failed with CertPathBuilderException!");
} catch (RepositoryException e) {
Throwable cause = ExceptionUtils.getRootCause(e);
if (!(cause instanceof CertPathBuilderException)) {
fail("should have failed with CertPathBuilderException but got " + e.getCause());
}
}
}
use of org.apache.jackrabbit.spi.RepositoryService in project jackrabbit by apache.
the class ConnectionTest method testObtainWithTLSSelfSignedCertAllowedAndHostnameVerificationDisabled.
public void testObtainWithTLSSelfSignedCertAllowedAndHostnameVerificationDisabled() throws RepositoryException, URISyntaxException {
Map<String, String> parameters = new HashMap<>();
ConnectionOptions.Builder builder = ConnectionOptions.builder();
builder.allowSelfSignedCertificates(true);
builder.disableHostnameVerification(true);
parameters.putAll(builder.build().toServiceFactoryParameters());
RepositoryService repositoryService = createRepositoryService(true, parameters);
repositoryService.obtain(new SimpleCredentials("admin", "admin".toCharArray()), null);
}
use of org.apache.jackrabbit.spi.RepositoryService in project jackrabbit by apache.
the class ConnectionTest method testObtainViaProxyWithValidCredentials.
public void testObtainViaProxyWithValidCredentials() throws URISyntaxException, RepositoryException {
ProxyAuthenticator authenticator = new ProxyAuthenticator() {
@Override
public String getRealm() {
return null;
}
@Override
public boolean authenticate(String userName, String password) {
if (userName.equals("test") && password.equals("valid")) {
return true;
}
return false;
}
};
HttpProxyServer proxyServer = DefaultHttpProxyServer.bootstrap().withPort(// use arbitrary port
0).withProxyAuthenticator(authenticator).start();
try {
Map<String, String> parameters = new HashMap<>();
ConnectionOptions.Builder builder = ConnectionOptions.builder();
builder.proxyHost("127.0.0.1");
builder.proxyPort(proxyServer.getListenAddress().getPort());
builder.proxyUsername("test");
builder.proxyPassword("valid");
parameters.putAll(builder.build().toServiceFactoryParameters());
RepositoryService repositoryService = createRepositoryService(false, parameters);
repositoryService.obtain(new SimpleCredentials("admin", "admin".toCharArray()), null);
} finally {
proxyServer.stop();
}
}
Aggregations