private String defaultUsername = "demo";
private String defaultPassword = "demo";
+ private Boolean forceDefaultCredentials = false;
public ThreadBoundJcrSessionFactory() {
Class<?>[] interfaces = { Session.class };
// first try to login without credentials, assuming the underlying login
// module will have dealt with authentication (typically using Spring
// Security)
- try {
- newSession = repository.login();
- } catch (LoginException e1) {
- log.warn("Cannot login without credentials: " + e1.getMessage());
- // invalid credentials, go to the next step
- } catch (RepositoryException e1) {
- // other kind of exception, fail
- throw new ArgeoException("Cannot log in to repository", e1);
- }
+ if (!forceDefaultCredentials)
+ try {
+ newSession = repository.login();
+ } catch (LoginException e1) {
+ log.warn("Cannot login without credentials: " + e1.getMessage());
+ // invalid credentials, go to the next step
+ } catch (RepositoryException e1) {
+ // other kind of exception, fail
+ throw new ArgeoException("Cannot log in to repository", e1);
+ }
// log using default username / password (useful for testing purposes)
if (newSession == null)
this.defaultPassword = defaultPassword;
}
+ public void setForceDefaultCredentials(Boolean forceDefaultCredentials) {
+ this.forceDefaultCredentials = forceDefaultCredentials;
+ }
+
}