Search in sources :

Example 1 with AclActions

use of alluxio.security.authorization.AclActions in project alluxio by Alluxio.

the class ProtoUtils method fromProto.

/**
 * @param acl the protobuf representation
 * @return {@link AccessControlList}
 */
public static AccessControlList fromProto(Acl.AccessControlList acl) {
    AccessControlList ret;
    if (acl.hasIsDefault() && acl.getIsDefault()) {
        ret = new DefaultAccessControlList();
    } else {
        ret = new AccessControlList();
    }
    ret.setOwningUser(acl.getOwningUser().intern());
    ret.setOwningGroup(acl.getOwningGroup().intern());
    if (acl.getIsEmpty()) {
        return ret;
    }
    // true if there are any extended entries (named user or named group)
    boolean hasExtended = false;
    for (Acl.NamedAclActions namedActions : acl.getUserActionsList()) {
        String name = namedActions.getName();
        AclActions actions = fromProto(namedActions.getActions());
        AclEntry entry;
        if (name.equals(AccessControlList.OWNING_USER_KEY)) {
            entry = new AclEntry.Builder().setType(AclEntryType.OWNING_USER).setSubject(acl.getOwningUser()).setActions(actions).build();
        } else {
            hasExtended = true;
            entry = new AclEntry.Builder().setType(AclEntryType.NAMED_USER).setSubject(name).setActions(actions).build();
        }
        ret.setEntry(entry);
    }
    for (Acl.NamedAclActions namedActions : acl.getGroupActionsList()) {
        String name = namedActions.getName();
        AclActions actions = fromProto(namedActions.getActions());
        AclEntry entry;
        if (name.equals(AccessControlList.OWNING_GROUP_KEY)) {
            entry = new AclEntry.Builder().setType(AclEntryType.OWNING_GROUP).setSubject(acl.getOwningGroup()).setActions(actions).build();
        } else {
            hasExtended = true;
            entry = new AclEntry.Builder().setType(AclEntryType.NAMED_GROUP).setSubject(name).setActions(actions).build();
        }
        ret.setEntry(entry);
    }
    if (hasExtended) {
        // Only set the mask if there are any extended acl entries.
        AclActions actions = fromProto(acl.getMaskActions());
        AclEntry entry = new AclEntry.Builder().setType(AclEntryType.MASK).setActions(actions).build();
        ret.setEntry(entry);
    }
    AclActions actions = fromProto(acl.getOtherActions());
    AclEntry entry = new AclEntry.Builder().setType(AclEntryType.OTHER).setActions(actions).build();
    ret.setEntry(entry);
    return ret;
}
Also used : DefaultAccessControlList(alluxio.security.authorization.DefaultAccessControlList) AccessControlList(alluxio.security.authorization.AccessControlList) DefaultAccessControlList(alluxio.security.authorization.DefaultAccessControlList) AclActions(alluxio.security.authorization.AclActions) AclEntry(alluxio.security.authorization.AclEntry) Acl(alluxio.proto.shared.Acl)

Example 2 with AclActions

use of alluxio.security.authorization.AclActions in project alluxio by Alluxio.

the class ProtoUtils method toProto.

/**
 * @param actions the {@link AclActions}
 * @return the protobuf representation of {@link AclActions}
 */
public static Acl.AclActions toProto(AclActions actions) {
    Acl.AclActions.Builder builder = Acl.AclActions.newBuilder();
    for (AclAction action : actions.getActions()) {
        Acl.AclAction pAction = toProto(action);
        builder.addActions(pAction);
    }
    return builder.build();
}
Also used : AclActions(alluxio.security.authorization.AclActions) SetAclAction(alluxio.grpc.SetAclAction) AclAction(alluxio.security.authorization.AclAction) Acl(alluxio.proto.shared.Acl)

Aggregations

Acl (alluxio.proto.shared.Acl)2 AclActions (alluxio.security.authorization.AclActions)2 SetAclAction (alluxio.grpc.SetAclAction)1 AccessControlList (alluxio.security.authorization.AccessControlList)1 AclAction (alluxio.security.authorization.AclAction)1 AclEntry (alluxio.security.authorization.AclEntry)1 DefaultAccessControlList (alluxio.security.authorization.DefaultAccessControlList)1