use of org.apache.jackrabbit.spi.PrivilegeDefinition in project jackrabbit by apache.
the class PrivilegeRecord method doWrite.
@Override
protected void doWrite() throws JournalException {
record.writeChar(IDENTIFIER);
record.writeInt(definitions.size());
for (PrivilegeDefinition def : definitions) {
record.writePrivilegeDef(def);
}
}
use of org.apache.jackrabbit.spi.PrivilegeDefinition in project jackrabbit by apache.
the class PrivilegeHandlerTest method testReadReader.
public void testReadReader() throws Exception {
InputStream in = getClass().getResourceAsStream("readtest.xml");
PrivilegeDefinitionReader reader = new PrivilegeDefinitionReader(new InputStreamReader(in), CONTENT_TYPE);
Map<Name, PrivilegeDefinition> defs = new HashMap<Name, PrivilegeDefinition>();
for (PrivilegeDefinition def : reader.getPrivilegeDefinitions()) {
defs.put(def.getName(), def);
}
for (PrivilegeDefinition def : DEF_EXPECTED) {
PrivilegeDefinition e = defs.remove(def.getName());
assertNotNull("Definition " + def.getName() + " missing");
assertEquals("Definition mismatch.", def, e);
}
assertTrue("Not all definitions present", defs.isEmpty());
// check for namespace
String fooUri = reader.getNamespaces().get(TEST_PREFIX);
assertEquals("Namespace included", TEST_URI, fooUri);
}
use of org.apache.jackrabbit.spi.PrivilegeDefinition in project jackrabbit by apache.
the class PrivilegeRegistry method createJcrWriteDefinition.
/**
* @return PrivilegeDefinition for the jcr:write privilege
*/
private static Definition createJcrWriteDefinition() {
Set<Name> jcrWriteAggregates = new HashSet<Name>(4);
jcrWriteAggregates.add(NameConstants.JCR_MODIFY_PROPERTIES);
jcrWriteAggregates.add(NameConstants.JCR_ADD_CHILD_NODES);
jcrWriteAggregates.add(NameConstants.JCR_REMOVE_CHILD_NODES);
jcrWriteAggregates.add(NameConstants.JCR_REMOVE_NODE);
int jcrWriteBits = NO_PRIVILEGE;
for (Name privilegeName : jcrWriteAggregates) {
jcrWriteBits |= PRIVILEGE_NAMES.get(privilegeName);
}
return new Definition(NameConstants.JCR_WRITE, false, jcrWriteAggregates, jcrWriteBits);
}
use of org.apache.jackrabbit.spi.PrivilegeDefinition in project jackrabbit by apache.
the class PrivilegeRegistry method externalRegisteredPrivileges.
//---------------------------------------------< PrivilegeEventListener >---
/**
* {@inheritDoc}
* @see PrivilegeEventListener#externalRegisteredPrivileges(java.util.Collection)
*/
public void externalRegisteredPrivileges(Collection<PrivilegeDefinition> definitions) throws RepositoryException {
Map<Name, PrivilegeDefinition> defs = new HashMap<Name, PrivilegeDefinition>(definitions.size());
for (PrivilegeDefinition d : definitions) {
defs.put(d.getName(), d);
}
registerCustomDefinitions(defs);
}
use of org.apache.jackrabbit.spi.PrivilegeDefinition in project jackrabbit by apache.
the class PrivilegeRegistry method createBuiltInPrivilegeDefinitions.
/**
* Creates <code>PrivilegeDefinition</code>s for all built-in privileges.
*
* @return definitions for all built-in privileges.
*/
private Map<Name, Definition> createBuiltInPrivilegeDefinitions() {
Map<Name, Definition> defs = new HashMap<Name, Definition>();
// all non-aggregate privileges
int jcrAllBits = NO_PRIVILEGE;
for (Name privilegeName : PRIVILEGE_NAMES.keySet()) {
int bits = PRIVILEGE_NAMES.get(privilegeName);
Definition def = new Definition(privilegeName, false, bits);
defs.put(privilegeName, def);
jcrAllBits |= bits;
}
// jcr:write
Definition jcrWrite = createJcrWriteDefinition();
defs.put(jcrWrite.getName(), jcrWrite);
// rep:write
Definition repWrite = createRepWriteDefinition(jcrWrite);
defs.put(repWrite.getName(), repWrite);
// jcr:all
Set<Name> jcrAllAggregates = new HashSet<Name>(10);
jcrAllAggregates.add(NameConstants.JCR_READ);
jcrAllAggregates.add(NameConstants.JCR_READ_ACCESS_CONTROL);
jcrAllAggregates.add(NameConstants.JCR_MODIFY_ACCESS_CONTROL);
jcrAllAggregates.add(NameConstants.JCR_LOCK_MANAGEMENT);
jcrAllAggregates.add(NameConstants.JCR_VERSION_MANAGEMENT);
jcrAllAggregates.add(NameConstants.JCR_NODE_TYPE_MANAGEMENT);
jcrAllAggregates.add(NameConstants.JCR_RETENTION_MANAGEMENT);
jcrAllAggregates.add(NameConstants.JCR_LIFECYCLE_MANAGEMENT);
jcrAllAggregates.add(NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT);
jcrAllAggregates.add(NameConstants.JCR_NAMESPACE_MANAGEMENT);
jcrAllAggregates.add(NameConstants.JCR_WORKSPACE_MANAGEMENT);
jcrAllAggregates.add(NameConstants.JCR_WRITE);
jcrAllAggregates.add(REP_WRITE_NAME);
jcrAllAggregates.add(REP_PRIVILEGE_MANAGEMENT_NAME);
Definition jcrAll = new Definition(NameConstants.JCR_ALL, false, jcrAllAggregates, jcrAllBits);
defs.put(jcrAll.getName(), jcrAll);
return defs;
}
Aggregations