@Override public EncryptionKey deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { JsonObject jsonObject = (JsonObject) jsonElement; EncryptionKey encryptionKey = new EncryptionKey(); try { encryptionKey.decode(HexUtil.hex2bytes(jsonObject.get("key").getAsString())); } catch (IOException e) { LOG.error("Fail to decode encryption key. " + e); } encryptionKey.setKvno(jsonObject.get("kvno").getAsInt()); return encryptionKey; }
@Override public EncryptionKey deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { JsonObject jsonObject = (JsonObject) jsonElement; EncryptionKey encryptionKey = new EncryptionKey(); try { encryptionKey.decode(HexUtil.hex2bytes(jsonObject.get("key").getAsString())); } catch (IOException e) { LOG.error("Fail to decode encryption key. " + e); } encryptionKey.setKvno(jsonObject.get("kvno").getAsInt()); return encryptionKey; }
/** * Get keys. * @throws IOException e * @return keys */ public List<EncryptionKey> getKeys() throws IOException { Iterator<Value> iterator1 = entry.get(KerberosAttribute.KRB5_KEY_AT).iterator(); List<EncryptionKey> keys = new ArrayList<>(); while (iterator1.hasNext()) { byte[] encryKey = iterator1.next().getBytes(); EncryptionKey key = new EncryptionKey(); key.decode(encryKey); key.setKvno(1); // TODO: kvno should be correctly stored and retrieved keys.add(key); } return keys; }
/** * Get keys. * @throws IOException e * @return keys */ public List<EncryptionKey> getKeys() throws IOException { Iterator<Value> iterator1 = entry.get(KerberosAttribute.KRB5_KEY_AT).iterator(); List<EncryptionKey> keys = new ArrayList<>(); while (iterator1.hasNext()) { byte[] encryKey = iterator1.next().getBytes(); EncryptionKey key = new EncryptionKey(); key.decode(encryKey); key.setKvno(1); // TODO: kvno should be correctly stored and retrieved keys.add(key); } return keys; }
public List<EncryptionKey> getKeys() throws KeeperException { String znode = IdentityZNodeHelper.getKeysZNode(this.identityName); if (ZKUtil.checkExists(this.zk, znode) == -1) { throw new IllegalArgumentException("The znode " + znode + " is not found"); } List<String> typeNames = ZKUtil.listChildrenNoWatch(this.zk, znode); List<EncryptionKey> keys = new ArrayList<>(typeNames.size()); for (String typeName : typeNames) { byte[] key = getEncryptionKey(typeName); EncryptionKey encryptionKey = new EncryptionKey(); try { encryptionKey.decode(key); } catch (IOException e) { LOG.error("Fail to decode the encryption key. " + e); } encryptionKey.setKvno(getEncryptionKeyNo(typeName)); keys.add(encryptionKey); } return keys; }