private static boolean isCompleteMessage(Object msg) { return msg == ReadyForQuery.INSTANCE || (msg instanceof Authentication && !((Authentication) msg).isAuthenticationOk()); }
Observable<? extends Message> authenticate(String username, String password, Message message) { return message instanceof Authentication && !((Authentication) message).isAuthenticationOk() ? stream.authenticate(new PasswordMessage(username, password, ((Authentication) message).getMd5Salt())) : Observable.just(message); }
@Override public Authentication read(ByteBuffer buffer) { int type = buffer.getInt(); switch (type) { case OK: return new Authentication(true, null); case CLEARTEXT_PASSWORD: return new Authentication(false, null); case PASSWORD_MD5_CHALLENGE: byte[] salt = new byte[4]; buffer.get(salt); return new Authentication(false, salt); default: throw new UnsupportedOperationException("Unsupported authentication type: " + type); } }
Observable<? extends Message> authenticate(String username, String password, Message message) { return message instanceof Authentication && !((Authentication) message).isAuthenticationOk() ? stream.authenticate(new PasswordMessage(username, password, ((Authentication) message).getMd5Salt())) : Observable.just(message); }
@Override public Authentication read(ByteBuffer buffer) { int type = buffer.getInt(); switch (type) { case OK: return new Authentication(true, null); case CLEARTEXT_PASSWORD: return new Authentication(false, null); case PASSWORD_MD5_CHALLENGE: byte[] salt = new byte[4]; buffer.get(salt); return new Authentication(false, salt); default: throw new UnsupportedOperationException("Unsupported authentication type: " + type); } }
private static boolean isCompleteMessage(Object msg) { return msg == ReadyForQuery.INSTANCE || (msg instanceof Authentication && !((Authentication) msg).isAuthenticationOk()); }