@Test public void testValidate() { thrown.expect(TokenException.class); thrown.expectMessage(Messages.WALLET_INVALID); Crypto crypto = Crypto.createPBKDF2Crypto(SampleKey.PASSWORD, prvKeyBytes); crypto.validate(); assertTrue("Should not throw any exception", true); crypto.cipher = "not-valid-ctr"; crypto.validate(); assertTrue("Shoud return in early statements", false); }
public void validate() { if ((!CTR.equals(cipher) && !CBC.equals(cipher)) || cipherparams == null || Strings.isNullOrEmpty(mac) || Strings.isNullOrEmpty(ciphertext) || kdfparams == null) { throw new TokenException(Messages.WALLET_INVALID); } cipherparams.validate(); kdfparams.validate(); }
Crypto { public void validate() { if ((!CTR.equals(cipher) && !CBC.equals(cipher)) || cipherparams == null || Strings.isNullOrEmpty(mac) || Strings.isNullOrEmpty(ciphertext) || kdfparams == null) { throw new TokenException(Messages.WALLET_INVALID); } cipherparams.validate(); kdfparams.validate(); } }
Crypto { public void validate() { if ((!CTR.equals(cipher) && !CBC.equals(cipher)) || cipherparams == null || Strings.isNullOrEmpty(mac) || Strings.isNullOrEmpty(ciphertext) || kdfparams == null) { throw new TokenException(Messages.WALLET_INVALID); } cipherparams.validate(); kdfparams.validate(); } Crypto(); }
Crypto { public void validate() { if ((!CTR.equals(cipher) && !CBC.equals(cipher)) || cipherparams == null || Strings.isNullOrEmpty(mac) || Strings.isNullOrEmpty(ciphertext) || kdfparams == null) { throw new TokenException(Messages.WALLET_INVALID); } cipherparams.validate(); kdfparams.validate(); } Crypto(); static Crypto createPBKDF2Crypto(String password, byte[] origin); static Crypto createPBKDF2CryptoWithKDFCached(String password, byte[] origin); static Crypto createSCryptCrypto(String password, byte[] origin); boolean verifyPassword(String password); void cacheDerivedKey(String password); void clearCachedDerivedKey(); void validate(); byte[] decrypt(String password); EncPair deriveEncPair(String password, byte[] origin); byte[] decryptEncPair(String password, EncPair encPair); @JsonProperty(required = true) String getCiphertext(); @JsonProperty(required = true) CipherParams getCipherparams(); @JsonProperty(required = true) String getMac(); @JsonProperty(required = true) String getCipher(); @JsonProperty(required = true) String getKdf(); @JsonProperty(required = true) T getKdfparams(); void setCiphertext(String ciphertext); void setMac(String mac); void setCipher(String cipher); void setCipherparams(CipherParams cipherparams); void setKdf(String kdf); void setKdfparams(T kdfparams); @Override boolean equals(Object o); @Override int hashCode(); }
Crypto { public void validate() { if ((!CTR.equals(cipher) && !CBC.equals(cipher)) || cipherparams == null || Strings.isNullOrEmpty(mac) || Strings.isNullOrEmpty(ciphertext) || kdfparams == null) { throw new TokenException(Messages.WALLET_INVALID); } cipherparams.validate(); kdfparams.validate(); } Crypto(); static Crypto createPBKDF2Crypto(String password, byte[] origin); static Crypto createPBKDF2CryptoWithKDFCached(String password, byte[] origin); static Crypto createSCryptCrypto(String password, byte[] origin); boolean verifyPassword(String password); void cacheDerivedKey(String password); void clearCachedDerivedKey(); void validate(); byte[] decrypt(String password); EncPair deriveEncPair(String password, byte[] origin); byte[] decryptEncPair(String password, EncPair encPair); @JsonProperty(required = true) String getCiphertext(); @JsonProperty(required = true) CipherParams getCipherparams(); @JsonProperty(required = true) String getMac(); @JsonProperty(required = true) String getCipher(); @JsonProperty(required = true) String getKdf(); @JsonProperty(required = true) T getKdfparams(); void setCiphertext(String ciphertext); void setMac(String mac); void setCipher(String cipher); void setCipherparams(CipherParams cipherparams); void setKdf(String kdf); void setKdfparams(T kdfparams); @Override boolean equals(Object o); @Override int hashCode();  }