private Map<TransportProtocolId, List<TransportConnectionInfo>> parseBootstrapServers( String serversStr) throws InvalidKeySpecException, NoSuchAlgorithmException { Map<TransportProtocolId, List<TransportConnectionInfo>> servers = new HashMap<>(); String[] serversSplit = serversStr.split(";"); for (String server : serversSplit) { if (server != null && !server.trim().isEmpty()) { String[] tokens = server.split(":"); ProtocolMetaData md = new ProtocolMetaData(); md.setAccessPointId(Integer.valueOf(tokens[0])); md.setProtocolVersionInfo( new ProtocolVersionPair(Integer.valueOf(tokens[1]), Integer.valueOf(tokens[2]))); md.setConnectionInfo(ByteBuffer.wrap(base64.decodeBase64(tokens[3]))); TransportProtocolId key = new TransportProtocolId( md.getProtocolVersionInfo().getId(), md.getProtocolVersionInfo().getVersion()); List<TransportConnectionInfo> serverList = servers.get(key); if (serverList == null) { serverList = new ArrayList<TransportConnectionInfo>(); servers.put(key, serverList); } serverList.add(new GenericTransportInfo(ServerType.BOOTSTRAP, md)); } } return servers; }
@Override public EndpointObjectHash getProfileHash() { return EndpointObjectHash.fromBytes( base64.decodeBase64( state .getProperty( PROFILE_HASH, new String(base64.encodeBase64(new byte[0]), Charsets.UTF_8)) .getBytes(Charsets.UTF_8))); }
private boolean isSDKPropertiesUpdated(KaaClientProperties sdkProperties) { byte[] hashFromSDK = sdkProperties.getPropertiesHash(); byte[] hashFromStateFile = base64.decodeBase64( state .getProperty( PROPERTIES_HASH, new String(base64.encodeBase64(new byte[0]), Charsets.UTF_8)) .getBytes(Charsets.UTF_8)); return !Arrays.equals(hashFromSDK, hashFromStateFile); }
@SuppressWarnings("unchecked") private void parseNfSubscriptions() { if (state.getProperty(NF_SUBSCRIPTIONS) != null) { byte[] data = base64.decodeBase64(state.getProperty(NF_SUBSCRIPTIONS)); ByteArrayInputStream is = new ByteArrayInputStream(data); try (ObjectInputStream ois = new ObjectInputStream(is)) { nfSubscriptions.putAll((Map<Long, Integer>) ois.readObject()); } catch (Exception e) { LOG.error( "Unexpected exception occurred while reading subscription information from state", e); } } else { LOG.info("No subscription info found in state"); } }
private void parseTopics() { if (state.getProperty(TOPIC_LIST) != null) { byte[] data = base64.decodeBase64(state.getProperty(TOPIC_LIST)); BinaryDecoder decoder = DecoderFactory.get().binaryDecoder(data, null); SpecificDatumReader<Topic> avroReader = new SpecificDatumReader<>(Topic.class); try { // NOSONAR Topic decodedTopic; while (!decoder.isEnd()) { decodedTopic = avroReader.read(null, decoder); LOG.debug("Loaded {}", decodedTopic); topicMap.put(decodedTopic.getId(), decodedTopic); } } catch (Exception e) { LOG.error("Unexpected exception occurred while reading information from decoder", e); } } else { LOG.info("No topic list found in state"); } }
public byte[] getDefaultConfigData() { String config = getProperty(KaaClientProperties.CONFIG_DATA_DEFAULT); return (config != null) ? base64.decodeBase64(config.getBytes(Charsets.UTF_8)) : null; }