Search in sources :

Example 1 with DefaultTestAccessRule

use of org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestAccessRule in project xwiki-platform by xwiki.

the class TestAccessRuleFactory method getNewInstance.

@Override
TestAccessRule getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes) {
    EntityReference userRef = parser.getResolver().resolve(attributes.getValue("name"), DefaultTestDocument.TYPE, new EntityReference(XWikiConstants.XWIKI_SPACE, EntityType.SPACE, parent.getReference().getRoot()));
    Boolean allow = name.startsWith("allow");
    String type = attributes.getValue("type");
    String user = parser.getSerializer().serialize(userRef);
    Boolean isUser = name.endsWith("User");
    if (type != null) {
        Right right = Right.toRight(type);
        new DefaultTestAccessRule(user, userRef, right, allow, isUser, parent);
    } else {
        EntityType parentType = parent.getType();
        if (parentType == EntityType.WIKI && ((TestWiki) parent).isMainWiki()) {
            // Null here means root (or farm)
            parentType = null;
        }
        for (Right right : Right.getEnabledRights(parentType)) {
            if (right != Right.CREATOR) {
                new DefaultTestAccessRule(user, userRef, right, allow, isUser, parent);
            }
        }
    }
    return null;
}
Also used : EntityType(org.xwiki.model.EntityType) DefaultTestAccessRule(org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestAccessRule) EntityReference(org.xwiki.model.reference.EntityReference) Right(org.xwiki.security.authorization.Right)

Aggregations

EntityType (org.xwiki.model.EntityType)1 EntityReference (org.xwiki.model.reference.EntityReference)1 Right (org.xwiki.security.authorization.Right)1 DefaultTestAccessRule (org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestAccessRule)1