public ComputeSessionCache decryptAndRetrieveSessionCache() throws ClientGeneralException { Object zkdata = null; ComputeSessionCache cache = null; try { LOGGER.debug("Attempt to fetch session info for {}", hostAddress); try { zkdata = distributedDataManager.getData(getNodePath(), false); } catch (Exception e) { throw new ClientGeneralException(ClientMessageKeys.DISTRIBUTED_DATA_CACHE_ERROR, e); } if (zkdata != null) { cache = (ComputeSessionCache) zkdata; } try { if (cache != null && cache.getSessionId() != null) { cache.setSessionId(encryptionProvider.decrypt(Base64.decodeBase64(cache.getSessionId()))); } } catch (Exception e) { throw new ClientGeneralException(ClientMessageKeys.DATA_ENCRYPTION_ERROR, e); } } catch (Exception e) { LOGGER.warn(e.getMessage()); } return cache; }
public void encryptAndUpdateSessionCache(ComputeSessionCache cache) throws ClientGeneralException { try { if (cache != null && cache.getSessionId() != null) { cache.setSessionId(encryptionProvider.getEncryptedString(cache.getSessionId())); } } catch (Exception e) { throw new ClientGeneralException(ClientMessageKeys.DATA_ENCRYPTION_ERROR, e); } try { distributedDataManager.putData(getNodePath(), cache); } catch (Exception e) { throw new ClientGeneralException(ClientMessageKeys.DISTRIBUTED_DATA_CACHE_ERROR, e); } }