@Override public void validate(String token) throws ConfigurationException { try { if (token.length() % 2 == 1) token = "0" + token; Hex.hexToBytes(token); } catch (NumberFormatException e) { throw new ConfigurationException("Token " + token + " contains non-hex digits"); } }
public String getKeyspace() throws InvalidRequestException { if (keyspace == null) throw new InvalidRequestException("No keyspace has been specified. USE a keyspace, or explicitly specify keyspace.tablename"); return keyspace; }
public AuthenticatedUser getAuthenticatedUser() throws AuthenticationException { if (!complete) throw new AuthenticationException("SASL negotiation not complete"); return authenticate(username, password); }
/** * Compose and add. * * @param entity * the entity * @param cqlMetadata * the cql metadata * @param thriftColumnValue * the thrift column value * @param thriftColumnName * the thrift column name */ private void composeAndAdd(HashMap entity, CqlMetadata cqlMetadata, Object thriftColumnValue, String thriftColumnName) { byte[] columnName = thriftColumnName.getBytes(); Map<ByteBuffer, String> schemaTypes = this.clientBase.getCqlMetadata().getValue_types(); AbstractType<?> type = null; try { type = TypeParser.parse(schemaTypes.get(ByteBuffer.wrap((byte[]) columnName))); } catch (SyntaxException | ConfigurationException e) { log.error(e.getMessage()); throw new KunderaException("Error while parsing CQL Type " + e); } entity.put(thriftColumnName, type.compose(ByteBuffer.wrap((byte[]) thriftColumnValue))); }
@Override public String toString() { return "ERROR " + error.code() + ": " + error.getMessage(); }
public void validateLogin() throws UnauthorizedException { if (user == null) throw new UnauthorizedException("You have not logged in"); }
public PreparedQueryNotFoundException(MD5Digest id) { super(ExceptionCode.UNPREPARED, makeMsg(id)); this.id = id; }
public void validateConfiguration() throws ConfigurationException { String pfilename = System.getProperty(SimpleAuthenticator.PASSWD_FILENAME_PROPERTY); if (pfilename == null) { throw new ConfigurationException("When using " + this.getClass().getCanonicalName() + " " + SimpleAuthenticator.PASSWD_FILENAME_PROPERTY + " properties must be defined."); } }
public String getKeyspace() throws InvalidRequestException { if (keyspace == null) throw new InvalidRequestException("No keyspace has been specified. USE a keyspace, or explicitly specify keyspace.tablename"); return keyspace; }
/** * Compose column value. * * @param cqlMetadata * the cql metadata * @param thriftColumnValue * the thrift column value * @param thriftColumnName * the thrift column name * @return the object */ private Object composeColumnValue(CqlMetadata cqlMetadata, byte[] thriftColumnValue, byte[] thriftColumnName) { Map<ByteBuffer, String> schemaTypes = cqlMetadata.getValue_types(); AbstractType<?> type = null; try { type = TypeParser.parse(schemaTypes.get(ByteBuffer.wrap(thriftColumnName))); } catch (SyntaxException | ConfigurationException ex) { log.error(ex.getMessage()); throw new KunderaException("Error while deserializing column value " + ex); } if (type.isCollection()) { return ((CollectionSerializer) type.getSerializer()) .deserializeForNativeProtocol(ByteBuffer.wrap(thriftColumnValue), ProtocolVersion.V2); } return type.compose(ByteBuffer.wrap(thriftColumnValue)); }
throw new AuthenticationException("The requested password check mode '" + pmode_plain + "' is not a valid mode. Possible values are " + mode_values); CharSequence user = credentials.get(USERNAME_KEY); if (null == user) throw new AuthenticationException("Authentication request was missing the required key '" + USERNAME_KEY + "'"); else CharSequence pass = credentials.get(PASSWORD_KEY); if (null == pass) throw new AuthenticationException("Authentication request was missing the required key '" + PASSWORD_KEY + "'"); else throw new AuthenticationException(authenticationErrorMessage(mode, username)); switch (mode) throw new AuthenticationException(authenticationErrorMessage(mode, username));
public void validateLogin() throws UnauthorizedException { if (user == null) throw new UnauthorizedException("You have not logged in"); }
public void validateConfiguration() throws ConfigurationException { String afilename = System.getProperty(ACCESS_FILENAME_PROPERTY); if (afilename == null) { throw new ConfigurationException(String.format("When using %s, '%s' property must be defined.", this .getClass().getCanonicalName(), ACCESS_FILENAME_PROPERTY)); } }
private void throwNestedNonFrozenError(Raw innerType) { if (innerType instanceof RawCollection) throw new InvalidRequestException("Non-frozen collections are not allowed inside collections: " + this); else throw new InvalidRequestException("Non-frozen UDTs are not allowed inside collections: " + this); }
log.error(e.getMessage()); throw new KunderaException("Error while getting instance of ListType " + e); log.error(e.getMessage()); throw new KunderaException("Error while getting instance of SetType " + e); log.error(e.getMessage()); throw new KunderaException("Error while getting instance of MapType " + e);
private static void validateKeyspace(String keyspace) throws InvalidRequestException { if (keyspace == null) throw new InvalidRequestException("You have not set a keyspace for this session"); }
log.error(e.getMessage()); throw new KunderaException("Error while getting instance of UserType " + e);
public void validateForWrite(String keyspaceName) throws InvalidRequestException { switch (this) { case SERIAL: case LOCAL_SERIAL: throw new InvalidRequestException("You must use conditional updates for serializable writes"); } }
public void validateForRead(String keyspaceName) throws InvalidRequestException { switch (this) { case ANY: throw new InvalidRequestException("ANY ConsistencyLevel is only supported for writes"); } }
public void validateForWrite(String keyspaceName) throws InvalidRequestException { switch (this) { case SERIAL: case LOCAL_SERIAL: throw new InvalidRequestException("You must use conditional updates for serializable writes"); } }