com.scalar.db.sql.exception.AuthorizationException Maven / Gradle / Ivy
package com.scalar.db.sql.exception;
import com.scalar.db.sql.Privilege;
import java.util.Optional;
import javax.annotation.Nullable;
public class AuthorizationException extends SqlException {
private final boolean superuserRequired;
@Nullable private final Privilege requiredPrivilege;
public AuthorizationException(
String message,
@Nullable String transactionId,
boolean superuserRequired,
@Nullable Privilege requiredPrivilege) {
super(message, transactionId);
this.superuserRequired = superuserRequired;
this.requiredPrivilege = requiredPrivilege;
}
public AuthorizationException(
String message,
Throwable cause,
@Nullable String transactionId,
boolean superuserRequired,
@Nullable Privilege requiredPrivilege) {
super(message, cause, transactionId);
this.superuserRequired = superuserRequired;
this.requiredPrivilege = requiredPrivilege;
}
public boolean isSuperuserRequired() {
return superuserRequired;
}
public Optional getRequiredPrivilege() {
return Optional.ofNullable(requiredPrivilege);
}
}