Revision: 47931
Author: uhommes
Date: 2015-01-05 16:22:14 +0100 (Mon, 05 Jan 2015)
Log Message:
-----------
REPO-1174 Allow anonymous login in PingServlet and make it the default
Modified Paths:
--------------
hippo-cms7/repository/branches/hippo-repository-2.24.xx/engine/src/main/java/org/onehippo/repository/update/UpdaterExecutor.java
hippo-cms7/repository/branches/hippo-repository-2.24.xx/servlets/src/main/java/org/hippoecm/repository/PingServlet.java
Modified:
hippo-cms7/repository/branches/hippo-repository-2.24.xx/engine/src/main/java/org/onehippo/repository/update/UpdaterExecutor.java
===================================================================
---
hippo-cms7/repository/branches/hippo-repository-2.24.xx/engine/src/main/java/org/onehippo/repository/update/UpdaterExecutor.java
2015-01-05 15:21:46 UTC (rev 47930)
+++
hippo-cms7/repository/branches/hippo-repository-2.24.xx/engine/src/main/java/org/onehippo/repository/update/UpdaterExecutor.java
2015-01-05 15:22:14 UTC (rev 47931)
@@ -137,7 +137,6 @@
} catch (RepositoryException e) {
error("Failed to log cancel event for " + updaterInfo.getName(),
e);
}
- report.finish();
cancelled = true;
}
Modified:
hippo-cms7/repository/branches/hippo-repository-2.24.xx/servlets/src/main/java/org/hippoecm/repository/PingServlet.java
===================================================================
---
hippo-cms7/repository/branches/hippo-repository-2.24.xx/servlets/src/main/java/org/hippoecm/repository/PingServlet.java
2015-01-05 15:21:46 UTC (rev 47930)
+++
hippo-cms7/repository/branches/hippo-repository-2.24.xx/servlets/src/main/java/org/hippoecm/repository/PingServlet.java
2015-01-05 15:22:14 UTC (rev 47931)
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2013 Hippo B.V. (http://www.onehippo.com)
+ * Copyright 2009-2015 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@
* <li>Check for static custom return message, else</li>
* <ul>
* <li>obtain the repository with the connection string</li>
- * <li>obtain the session with the specified username and password</li>
+ * <li>obtain the session with the specified username and password or an
anonymous session</li>
* <li>try to read the check node</li>
* <li>try to write to the repository if enabled</li>
* <li>logout and close jcr session</li>
@@ -49,7 +49,8 @@
* printed and a 500 (internal server error) status is returned.</p>
* <p>In case the custom message is provided, a service unavailable error
(503) is returned</p>
*
- * <p>To enable the servlet add the following to your web.xml</p>
+ * <p>To enable the servlet add the following to your web.xml. Set the
username to anonymous or leave out the username
+ * for anonymous checks.</p>
* <code><![CDATA[
<servlet>
<servlet-name>PingServlet</servlet-name>
@@ -105,9 +106,9 @@
/** Default values */
private static final String DEFAULT_REPOSITORY_ADDRESS = "vm://";
- private static final String DEFAULT_USERNAME = "admin";
- private static final String DEFAULT_PASSWORD = "admin";
- private static final String DEFAULT_NODE = "content/documents";
+ private static final String DEFAULT_USERNAME = "anonymous";
+ private static final String DEFAULT_PASSWORD = "";
+ private static final String DEFAULT_NODE = "";
private static final String DEFAULT_WRITE_ENABLE = "false";
private static final String DEFAULT_WRITE_PATH = "pingcheck";
private static final String DEFAULT_CLUSTER_NODE_ID = "default";
@@ -253,6 +254,9 @@
obtainRepository();
}
try {
+ if (username.isEmpty() || "anonymous".equalsIgnoreCase(username)) {
+ return repository.login();
+ }
return repository.login(username, password.toCharArray());
} catch (LoginException e) {
String msg = "FAILURE - Wrong credentials for obtaining session
from repository in ping servlet : " + ""
@@ -278,7 +282,7 @@
private void doReadTest(Session session) throws PingException {
String msg;
try {
- if (checkNode.length() == 0) {
+ if (checkNode.isEmpty()) {
session.getRootNode();
} else {
session.getRootNode().getNode(checkNode);
_______________________________________________
Hippocms-svn mailing list
[email protected]
https://lists.onehippo.org/mailman/listinfo/hippocms-svn