/** * @param password the password to set */ public void setPassword(String password) { this.password = password==null?null:PwEncoder.encode(password); }
/** * @return the password */ public String getPassword() { return password==null?null:PwEncoder.decode(password); }
public static String encode(String msg) { try { SecretKeySpec keySpec = new SecretKeySpec(getKey(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, keySpec); byte[] input = msg.getBytes(); byte[] encrypted = cipher.doFinal(input); return DatatypeConverter.printBase64Binary(encrypted); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("Error while encoding", ex); } catch (NoSuchPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (IllegalBlockSizeException ex) { throw new RuntimeException("Error while encoding", ex); } catch (BadPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (InvalidKeyException ex) { throw new RuntimeException("Error while encoding", ex); } }
public static String encode(String msg) { try { SecretKeySpec keySpec = new SecretKeySpec(getKey(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, keySpec); byte[] input = msg.getBytes(); byte[] encrypted = cipher.doFinal(input); return DatatypeConverter.printBase64Binary(encrypted); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("Error while encoding", ex); } catch (NoSuchPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (IllegalBlockSizeException ex) { throw new RuntimeException("Error while encoding", ex); } catch (BadPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (InvalidKeyException ex) { throw new RuntimeException("Error while encoding", ex); } }
/** * @param password the password to set */ public void setPassword(String password) { this.password = password==null?null:PwEncoder.encode(password); }
public static String decode(String msg) { try { SecretKeySpec keySpec = new SecretKeySpec(getKey(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, keySpec); byte[] de64 = DatatypeConverter.parseBase64Binary(msg); byte[] decrypted = cipher.doFinal(de64); return new String(decrypted); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("Error while encoding", ex); } catch (NoSuchPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (IllegalBlockSizeException ex) { throw new RuntimeException("Error while encoding", ex); } catch (BadPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (InvalidKeyException ex) { throw new RuntimeException("Error while encoding", ex); } } }
/** * @return the password */ public String getPassword() { return password==null?null:PwEncoder.decode(password); }
/** * @param password the password to set */ public void setPassword(String password) { this.password = password==null?null:PwEncoder.encode(password); }
public static String decode(String msg) { try { SecretKeySpec keySpec = new SecretKeySpec(getKey(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, keySpec); byte[] de64 = DatatypeConverter.parseBase64Binary(msg); byte[] decrypted = cipher.doFinal(de64); return new String(decrypted); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("Error while encoding", ex); } catch (NoSuchPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (IllegalBlockSizeException ex) { throw new RuntimeException("Error while encoding", ex); } catch (BadPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (InvalidKeyException ex) { throw new RuntimeException("Error while encoding", ex); } } }
/** * @return the password */ public String getPassword() { return password==null?null:PwEncoder.decode(password); }
/** * @param password the password to set */ public void setPassword(String password) { this.password = password==null?null:PwEncoder.encode(password); }
public static String encode(String msg) { try { SecretKeySpec keySpec = new SecretKeySpec(getKey(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, keySpec); byte[] input = msg.getBytes(); byte[] encrypted = cipher.doFinal(input); return DatatypeConverter.printBase64Binary(encrypted); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("Error while encoding", ex); } catch (NoSuchPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (IllegalBlockSizeException ex) { throw new RuntimeException("Error while encoding", ex); } catch (BadPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (InvalidKeyException ex) { throw new RuntimeException("Error while encoding", ex); } }
/** * @return the password */ public String getPassword() { return password==null?null:PwEncoder.decode(password); }
private RESTOutputInstance toOutputInstance(GSInstance i) { RESTOutputInstance ret = new RESTOutputInstance(); ret.setId(i.getId()); ret.setName(i.getName()); ret.setDescription(i.getDescription()); ret.setBaseURL(i.getBaseURL()); ret.setUsername(i.getUsername()); ret.setPassword(PwEncoder.encode(i.getPassword())); ret.setCreationDate(i.getDateCreation().toString()); return ret; }
public static String decode(String msg) { try { SecretKeySpec keySpec = new SecretKeySpec(getKey(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, keySpec); byte[] de64 = DatatypeConverter.parseBase64Binary(msg); byte[] decrypted = cipher.doFinal(de64); return new String(decrypted); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("Error while encoding", ex); } catch (NoSuchPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (IllegalBlockSizeException ex) { throw new RuntimeException("Error while encoding", ex); } catch (BadPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (InvalidKeyException ex) { throw new RuntimeException("Error while encoding", ex); } } }
public static String encode(String msg) { try { SecretKeySpec keySpec = new SecretKeySpec(getKey(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, keySpec); byte[] input = msg.getBytes(); byte[] encrypted = cipher.doFinal(input); return DatatypeConverter.printBase64Binary(encrypted); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("Error while encoding", ex); } catch (NoSuchPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (IllegalBlockSizeException ex) { throw new RuntimeException("Error while encoding", ex); } catch (BadPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (InvalidKeyException ex) { throw new RuntimeException("Error while encoding", ex); } }
public static String decode(String msg) { try { SecretKeySpec keySpec = new SecretKeySpec(getKey(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, keySpec); byte[] de64 = DatatypeConverter.parseBase64Binary(msg); byte[] decrypted = cipher.doFinal(de64); return new String(decrypted); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("Error while encoding", ex); } catch (NoSuchPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (IllegalBlockSizeException ex) { throw new RuntimeException("Error while encoding", ex); } catch (BadPaddingException ex) { throw new RuntimeException("Error while encoding", ex); } catch (InvalidKeyException ex) { throw new RuntimeException("Error while encoding", ex); } } }