use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.
the class CompatibilityIssuesTest method testSearchDescendentUsingXPath.
@Test
public void testSearchDescendentUsingXPath() throws Exception {
Session adminSession = getAdminSession();
String testNodePath = "/home/users/geometrixx-outdoors/emily.andrews@mailinator.com/social/relationships/following/aaron.mcdonald@mailinator.com";
Node testNode = JcrUtils.getOrCreateByPath(testNodePath, null, adminSession);
testNode.setProperty("id", "aaron.mcdonald@mailinator.com");
AccessControlManager acMgr = adminSession.getAccessControlManager();
JackrabbitAccessControlList tmpl = AccessControlUtils.getAccessControlList(acMgr, "/home/users/geometrixx-outdoors");
ValueFactory vf = adminSession.getValueFactory();
Map<String, Value> restrictions = new HashMap<String, Value>();
restrictions.put("rep:glob", vf.createValue("*/social/relationships/following/*"));
tmpl.addEntry(EveryonePrincipal.getInstance(), new Privilege[] { acMgr.privilegeFromName(Privilege.JCR_READ) }, true, restrictions);
acMgr.setPolicy(tmpl.getPath(), tmpl);
adminSession.save();
Session anonymousSession = getRepository().login(new GuestCredentials());
QueryManager qm = anonymousSession.getWorkspace().getQueryManager();
Query q = qm.createQuery("/jcr:root/home//social/relationships/following//*[@id='aaron.mcdonald@mailinator.com']", Query.XPATH);
QueryResult r = q.execute();
RowIterator it = r.getRows();
Assert.assertTrue(it.hasNext());
anonymousSession.logout();
}
use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.
the class PreAuthDefaultExternalLoginModuleTest method testGuest.
@Test
public void testGuest() throws Exception {
ContentSession cs = null;
try {
cs = login(new GuestCredentials());
assertEquals(UserConstants.DEFAULT_ANONYMOUS_ID, cs.getAuthInfo().getUserID());
} finally {
if (cs != null) {
cs.close();
}
}
}
use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.
the class AbstractLoginTest method buildCredentials.
private Credentials buildCredentials(Repository repository, Credentials credentials) throws RepositoryException {
Credentials creds;
if ("admin".equals(runAsUser)) {
creds = credentials;
} else if ("anonymous".equals(runAsUser)) {
creds = new GuestCredentials();
} else {
creds = new SimpleCredentials(USER, USER.toCharArray());
}
if (runWithToken) {
Configuration.setConfiguration(ConfigurationUtil.getJackrabbit2Configuration(ConfigurationParameters.EMPTY));
if (creds instanceof SimpleCredentials) {
SimpleCredentials sc = (SimpleCredentials) creds;
sc.setAttribute(".token", "");
repository.login(sc).logout();
creds = new TokenCredentials(sc.getAttribute(".token").toString());
} else {
throw new UnsupportedOperationException();
}
}
return creds;
}
use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.
the class CugPermissionProviderTest method testIsGrantedNonExistingLocation.
/**
* @see org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider#isGranted(org.apache.jackrabbit.oak.plugins.tree.TreeLocation, long)
*/
@Test
public void testIsGrantedNonExistingLocation() throws Exception {
ContentSession anonymous = login(new GuestCredentials());
try {
// additionally create a root that doesn't have access to the root node
Root anonymousRoot = anonymous.getLatestRoot();
for (Root r : new Root[] { anonymousRoot, root }) {
TreeLocation location = TreeLocation.create(r, "/path/to/non/existing/tree");
assertFalse(cugPermProvider.isGranted(location, Permissions.READ));
assertFalse(cugPermProvider.isGranted(location, Permissions.READ_NODE));
assertFalse(cugPermProvider.isGranted(location, Permissions.READ_PROPERTY));
assertFalse(cugPermProvider.isGranted(location, Permissions.ALL));
assertFalse(cugPermProvider.isGranted(location, Permissions.ADD_NODE));
assertFalse(cugPermProvider.isGranted(location, Permissions.READ_ACCESS_CONTROL));
}
} finally {
anonymous.close();
}
}
Aggregations