public static Permission toPermission(AccessControlProtos.Permission proto) {
    if (proto.getType() == AccessControlProtos.Permission.Type.Global) {
      AccessControlProtos.GlobalPermission perm = proto.getGlobalPermission();
      Permission.Action[] actions = toPermissionActions(perm.getActionList());
      return Permission.newBuilder().withActions(actions).build();
    }
    if (proto.getType() == AccessControlProtos.Permission.Type.Namespace) {
      AccessControlProtos.NamespacePermission perm = proto.getNamespacePermission();
      Permission.Action[] actions = toPermissionActions(perm.getActionList());
      if (!proto.hasNamespacePermission()) {
        throw new IllegalStateException("Namespace must not be empty in NamespacePermission");
      }
      return Permission.newBuilder(perm.getNamespaceName().toStringUtf8()).withActions(actions)
        .build();
    }
    if (proto.getType() == AccessControlProtos.Permission.Type.Table) {
      AccessControlProtos.TablePermission perm = proto.getTablePermission();
      Permission.Action[] actions = toPermissionActions(perm.getActionList());
      if (!perm.hasTableName()) {
        throw new IllegalStateException("TableName cannot be empty");
      }
      TableName table = ProtobufUtil.toTableName(perm.getTableName());
      byte[] family = null;
      byte[] qualifier = null;
      if (perm.hasFamily()) {
        family = perm.getFamily().toByteArray();
      }
      if (perm.hasQualifier()) {
        qualifier = perm.getQualifier().toByteArray();
      }
      return Permission.newBuilder(table).withFamily(family).withQualifier(qualifier)
        .withActions(actions).build();
    }
    throw new IllegalStateException("Unrecognize Perm Type: " + proto.getType());
  }
Converts a Permission proto to a client Permission object.
@param proto the protobuf Permission
@return the converted Permission
hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlUtil.java