use of org.apache.jackrabbit.core.SessionImpl in project jackrabbit by apache.
the class AuthorizableImplTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
if (superuser instanceof SessionImpl) {
NameResolver resolver = (SessionImpl) superuser;
protectedUserProps.add(resolver.getJCRName(UserConstants.P_PASSWORD));
protectedUserProps.add(resolver.getJCRName(UserConstants.P_IMPERSONATORS));
protectedUserProps.add(resolver.getJCRName(UserConstants.P_PRINCIPAL_NAME));
protectedUserProps.add(resolver.getJCRName(UserConstants.P_DISABLED));
protectedGroupProps.add(resolver.getJCRName(UserConstants.P_MEMBERS));
protectedGroupProps.add(resolver.getJCRName(UserConstants.P_PRINCIPAL_NAME));
} else {
throw new NotExecutableException();
}
}
use of org.apache.jackrabbit.core.SessionImpl in project jackrabbit by apache.
the class SessionImplTest method testGetSubject.
/**
* JCR-2895 : SessionImpl#getSubject() should return an unmodifiable subject
*
* @see <a href="https://issues.apache.org/jira/browse/JCR-2895">JCR-2895</a>
*/
public void testGetSubject() {
Subject subject = ((SessionImpl) superuser).getSubject();
assertFalse(subject.getPublicCredentials().isEmpty());
assertFalse(subject.getPublicCredentials(Credentials.class).isEmpty());
assertFalse(subject.getPrincipals().isEmpty());
assertTrue(subject.isReadOnly());
try {
subject.getPublicCredentials().add(new SimpleCredentials("test", new char[0]));
fail("Subject expected to be readonly");
} catch (IllegalStateException e) {
// success
}
try {
subject.getPrincipals().add(new PrincipalImpl("test"));
fail("Subject expected to be readonly");
} catch (IllegalStateException e) {
// success
}
}
use of org.apache.jackrabbit.core.SessionImpl in project jackrabbit by apache.
the class TokenProviderTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
if (superuser instanceof SessionImpl) {
UserManager umgr = ((SessionImpl) superuser).getUserManager();
if (!umgr.isAutoSave()) {
umgr.autoSave(true);
}
String uid = "test";
while (umgr.getAuthorizable(uid) != null) {
uid += "_";
}
testuser = umgr.createUser(uid, uid);
userId = testuser.getID();
} else {
throw new NotExecutableException();
}
if (superuser.nodeExists(((ItemBasedPrincipal) testuser.getPrincipal()).getPath())) {
session = (SessionImpl) superuser;
} else {
session = (SessionImpl) getHelper().getSuperuserSession("security");
}
tokenProvider = new TokenProvider((SessionImpl) session, TokenBasedAuthentication.TOKEN_EXPIRATION);
}
use of org.apache.jackrabbit.core.SessionImpl in project jackrabbit by apache.
the class GarbageCollector method mark.
public void mark() throws RepositoryException {
if (store == null) {
throw new RepositoryException("No DataStore configured.");
}
long now = System.currentTimeMillis();
if (startScanTimestamp == 0) {
startScanTimestamp = now;
store.updateModifiedDateOnAccess(startScanTimestamp);
}
if (pmList == null || !persistenceManagerScan) {
for (SessionImpl s : sessionList) {
scanNodes(s);
}
} else {
try {
if (!NODE_ID_SCAN) {
scanPersistenceManagersByNodeInfos();
} else {
scanPersistenceManagersByNodeIds();
}
} catch (ItemStateException e) {
throw new RepositoryException(e);
}
}
}
use of org.apache.jackrabbit.core.SessionImpl in project jackrabbit by apache.
the class LockManagerImpl method internalUnlock.
/**
* Unlock a node (internal implementation)
* @param node node to unlock
* @throws LockException if the node can not be unlocked
* @throws RepositoryException if another error occurs
*/
boolean internalUnlock(NodeImpl node) throws LockException, RepositoryException {
ClusterOperation operation = null;
boolean successful = false;
if (eventChannel != null) {
operation = eventChannel.create(node.getNodeId());
}
acquire();
try {
SessionImpl session = (SessionImpl) node.getSession();
// check whether node is locked by this session
PathMap.Element<LockInfo> element = lockMap.map(getPath(session, node.getId()), true);
if (element == null) {
throw new LockException("Node not locked: " + node);
}
LockInfo info = element.get();
if (info == null) {
throw new LockException("Node not locked: " + node);
}
checkUnlock(info, session);
getSessionLockManager(session).lockTokenRemoved(info.getLockToken());
element.set(null);
info.setLive(false);
if (!info.isSessionScoped()) {
save();
successful = true;
}
return true;
} finally {
release();
if (operation != null) {
operation.ended(successful);
}
}
}
Aggregations