com.kolibrifx.plovercrest.server.internal.protocol.AccessControlUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plovercrest-server Show documentation
Show all versions of plovercrest-server Show documentation
Plovercrest server library.
The newest version!
/*
* Copyright (c) 2010-2017, KolibriFX AS. Licensed under the Apache License, version 2.0.
*/
package com.kolibrifx.plovercrest.server.internal.protocol;
import com.kolibrifx.plovercrest.client.internal.RemoteCommand;
import com.kolibrifx.plovercrest.server.security.AccessKind;
public final class AccessControlUtils {
private AccessControlUtils() {
}
/**
* Returns an access kind for the given command, or null
if all clients should be
* allowed.
*/
public static AccessKind getAccessKindForCommand(final RemoteCommand command) {
switch (command) {
case CREATE:
case CREATE_TABLE_IF_MISSING:
return AccessKind.CREATE;
case DELETE:
return AccessKind.DELETE;
case RENAME:
return AccessKind.RENAME;
case FLUSH:
case FREEZE:
case MULTI_WRITE:
case MULTI_WRITE_ACK:
case MULTI_WRITE_INIT:
case UNFREEZE:
case WRITE:
return AccessKind.WRITE;
case OPEN:
case READ_CONTINUE_NON_OVERLAPPING:
case READ_CONTINUE_OVERLAPPING:
case READ_ELEMENT_INDEX:
case READ_START_NON_OVERLAPPING:
case READ_START_OVERLAPPING:
case SUBSCRIBE:
case TABLE_INFO:
return AccessKind.READ;
case HANDSHAKE: // always allowed, needed to initialize ClientInfo
case UNSUBSCRIBE:
return null;
case LIST:
case SUBSCRIBE_GLOBAL: // table names subscription
return AccessKind.LIST;
default:
throw new IllegalStateException("Unhandled command " + command);
}
}
}