/** * Sets the authenticated client ID. This is meant to be used by the authentication layer. * * Trying to set a different client ID after it's been set will result in an exception. */ public void setClientId(String id) { Preconditions.checkState(clientId == null, "Client ID has already been set."); this.clientId = id; }
private void checkParent(byte[] prefix) { if (prefix != null) { Preconditions.checkState(parent != null, "Parent prefix provided for parent index."); } else { Preconditions.checkState(parent == null, "Parent prefix missing for child index."); } }
private void checkParent(byte[] prefix) { if (prefix != null) { Preconditions.checkState(parent != null, "Parent prefix provided for parent index."); } else { Preconditions.checkState(parent == null, "Parent prefix missing for child index."); } }
TransportCipher sessionCipher() { Preconditions.checkState(sessionCipher != null); return sessionCipher; }
TransportCipher sessionCipher() { Preconditions.checkState(sessionCipher != null); return sessionCipher; }
/** * Sets the authenticated client ID. This is meant to be used by the authentication layer. * * Trying to set a different client ID after it's been set will result in an exception. */ public void setClientId(String id) { Preconditions.checkState(clientId == null, "Client ID has already been set."); this.clientId = id; }
/** * Sets the authenticated client ID. This is meant to be used by the authentication layer. * * Trying to set a different client ID after it's been set will result in an exception. */ public void setClientId(String id) { Preconditions.checkState(clientId == null, "Client ID has already been set."); this.clientId = id; }
public void setInterceptor(Interceptor interceptor) { Preconditions.checkState(this.interceptor == null, "Already have an interceptor."); this.interceptor = interceptor; }
public void setInterceptor(Interceptor interceptor) { Preconditions.checkState(this.interceptor == null, "Already have an interceptor."); this.interceptor = interceptor; }
TransportCipher sessionCipher() { Preconditions.checkState(sessionCipher != null); return sessionCipher; }
public void setInterceptor(Interceptor interceptor) { Preconditions.checkState(this.interceptor == null, "Already have an interceptor."); this.interceptor = interceptor; }
/** * Creates a key prefix for child indices of this index. This allows the prefix to be * calculated only once, avoiding redundant work when multiple child indices of the * same parent index exist. */ byte[] childPrefix(Object value) { Preconditions.checkState(parent == null, "Not a parent index."); return buildKey(name, toParentKey(value)); }
/** * Creates a key prefix for child indices of this index. This allows the prefix to be * calculated only once, avoiding redundant work when multiple child indices of the * same parent index exist. */ byte[] childPrefix(Object value) { Preconditions.checkState(parent == null, "Not a parent index."); return buildKey(name, toParentKey(value)); }
private byte[] doCipherOp(CryptoCipher cipher, byte[] in, boolean isFinal) throws GeneralSecurityException { Preconditions.checkState(cipher != null); int scale = 1; while (true) { int size = in.length * scale; byte[] buffer = new byte[size]; try { int outSize = isFinal ? cipher.doFinal(in, 0, in.length, buffer, 0) : cipher.update(in, 0, in.length, buffer, 0); if (outSize != buffer.length) { byte[] output = new byte[outSize]; System.arraycopy(buffer, 0, output, 0, output.length); return output; } else { return buffer; } } catch (ShortBufferException e) { // Try again with a bigger buffer. scale *= 2; } } }
private byte[] doCipherOp(CryptoCipher cipher, byte[] in, boolean isFinal) throws GeneralSecurityException { Preconditions.checkState(cipher != null); int scale = 1; while (true) { int size = in.length * scale; byte[] buffer = new byte[size]; try { int outSize = isFinal ? cipher.doFinal(in, 0, in.length, buffer, 0) : cipher.update(in, 0, in.length, buffer, 0); if (outSize != buffer.length) { byte[] output = new byte[outSize]; System.arraycopy(buffer, 0, output, 0, output.length); return output; } else { return buffer; } } catch (ShortBufferException e) { // Try again with a bigger buffer. scale *= 2; } } }
private byte[] doCipherOp(CryptoCipher cipher, byte[] in, boolean isFinal) throws GeneralSecurityException { Preconditions.checkState(cipher != null); int scale = 1; while (true) { int size = in.length * scale; byte[] buffer = new byte[size]; try { int outSize = isFinal ? cipher.doFinal(in, 0, in.length, buffer, 0) : cipher.update(in, 0, in.length, buffer, 0); if (outSize != buffer.length) { byte[] output = new byte[outSize]; System.arraycopy(buffer, 0, output, 0, output.length); return output; } else { return buffer; } } catch (ShortBufferException e) { // Try again with a bigger buffer. scale *= 2; } } }
try { String secret = secretKeyHolder.getSecretKey(challenge.appId); Preconditions.checkState(secret != null, "Trying to authenticate non-registered app %s.", challenge.appId); LOG.debug("Authenticating challenge for app {}.", challenge.appId);
try { String secret = secretKeyHolder.getSecretKey(challenge.appId); Preconditions.checkState(secret != null, "Trying to authenticate non-registered app %s.", challenge.appId); LOG.debug("Authenticating challenge for app {}.", challenge.appId);
try { String secret = secretKeyHolder.getSecretKey(challenge.appId); Preconditions.checkState(secret != null, "Trying to authenticate non-registered app %s.", challenge.appId); LOG.debug("Authenticating challenge for app {}.", challenge.appId);