private String getSHA1(byte[] input) {
   try {
     byte[] digestBytes = WSSecurityUtil.generateDigest(input);
     return Base64.encode(digestBytes);
   } catch (WSSecurityException e) {
     // REVISIT
   }
   return null;
 }
 String encrypt(String clearText) {
   String sha1Hash = null;
   try {
     MessageDigest md = MessageDigest.getInstance("SHA1"); // $NON-NLS-1$
     byte[] digest = md.digest(clearText.getBytes());
     sha1Hash = new String(Base64.encode(digest));
   } catch (Exception e) {
     e.printStackTrace();
   }
   return sha1Hash;
 }
예제 #3
0
 /**
  * Method getDecodedBase64EncodedData
  *
  * @param element
  * @return a byte array containing the decoded data
  * @throws WSSecurityException
  */
 public static byte[] getDecodedBase64EncodedData(Element element) throws WSSecurityException {
   StringBuffer sb = new StringBuffer();
   NodeList children = element.getChildNodes();
   int iMax = children.getLength();
   for (int i = 0; i < iMax; i++) {
     Node curr = children.item(i);
     if (curr.getNodeType() == Node.TEXT_NODE) {
       sb.append(((Text) curr).getData());
     }
   }
   String encodedData = sb.toString();
   return Base64.decode(encodedData);
 }