发送裂变红包

@param key
商户KEY
@param wxRedPackGroup
红包内容
@param file
证书文件
@param password
证书密码
@return
166780
@Override
    public NutMap send_redpackgroup(String key, WxPayRedPackGroup wxRedPackGroup, File file, String password) {
        String url = payBase + "/mmpaymkttransfers/sendgroupredpack";
        Map<String, Object> params = Lang.obj2map(wxRedPackGroup);
        return this.postPay(url, key, params, file, password);
    }
912832
public Response put(File file, String key, String token) throws QiniuException {
        return put(file, key, token, null, null, false);
    }
792003
public EncryptionKey loadKeyUsingPassword(String password) {
        if (password == null || password.equals("")) {
            throw new IllegalArgumentException("password is required to be a non-null/non-empty " +
                    "string");
        }
        KeyData data = this.storage.getEncryptionKeyData();
        if (data == null || !validateEncryptionKeyData(data)) {
            return null;
        }

        EncryptionKey dpk = null;
        SecretKey aesKey = null;
        try {
            aesKey = pbkdf2DerivedKeyForPassword(password, data.getSalt(), data.iterations,
                    ENCRYPTION_KEYCHAIN_AES_KEY_SIZE);
            byte[] dpkBytes = DPKEncryptionUtil.decryptAES(aesKey, data.getIv(), data
                    .getEncryptedDPK());
            dpk = new EncryptionKey(dpkBytes);
        } catch (NoSuchAlgorithmException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        } catch (InvalidKeySpecException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        } catch (IllegalBlockSizeException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        } catch (InvalidKeyException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        } catch (BadPaddingException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        } catch (InvalidAlgorithmParameterException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        } catch (NoSuchPaddingException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        }

        return dpk;
    }
1003183
public void setKeyManagerFactoryKeyStorePassword(String password) {
        if (password != null) {
            this.keyManagerFactoryKeyStorePassword = password.toCharArray();
        } else {
            this.keyManagerFactoryKeyStorePassword = null;
        }
    }
944747
public static boolean validatePassword(BrokerSession session, String password) {
        password = encrypt(password, session.getServerCaps().getCipherKey());
        return session.callRPCBool("RGCWFUSR VALIDPSW", password);
    }
132252
protected final String groupKey(CDXLine line) {
		String timestamp = line.getTimestamp();
		return timestamp.substring(0,
			Math.min(timestampDedupLength, timestamp.length()));
	}
170075
public static boolean isLegalPropertyKey(String key)
  {

    return (key.equals(OutputKeys.CDATA_SECTION_ELEMENTS)
            || key.equals(OutputKeys.DOCTYPE_PUBLIC)
            || key.equals(OutputKeys.DOCTYPE_SYSTEM)
            || key.equals(OutputKeys.ENCODING)
            || key.equals(OutputKeys.INDENT)
            || key.equals(OutputKeys.MEDIA_TYPE)
            || key.equals(OutputKeys.METHOD)
            || key.equals(OutputKeys.OMIT_XML_DECLARATION)
            || key.equals(OutputKeys.STANDALONE)
            || key.equals(OutputKeys.VERSION)
            || (key.length() > 0) 
                  && (key.charAt(0) == '{') 
                  && (key.lastIndexOf('{') == 0)
                  && (key.indexOf('}') > 0)
                  && (key.lastIndexOf('}') == key.indexOf('}')));
  }
368407
@Override
    public byte[] get(String key) {
        File f = new File(directory, hash(key));
        FileInputStream fi = null;
        byte[] data = null;
        int read = 0;
        try {
            if (outOfDate(f)) {
                f.delete();
                return null;
            }
            data = new byte[(int) f.length()];
            fi = new FileInputStream(f);
            read = fi.read(data);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (fi != null) {
            try {
                fi.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        if (read == 0) {
            return null;
        }
        return data;
    }
385865
public String toEncryptedXml(WxMpConfigStorage wxMpConfigStorage) {
    String plainXml = toXml();
    WxMpCryptUtil pc = new WxMpCryptUtil(wxMpConfigStorage);
    return pc.encrypt(plainXml);
  }
961840
public static void mapZipFile(final byte[] zipFile, final Map<String, byte[]> output, final String keyPrefix,
            final String keyUnPrefix) {
        try {
            final String fixedKeyPrefix = keyPrefix == null ? "" : keyPrefix;
            final String fixedKeyUnPrefix = keyUnPrefix == null ? "" : keyUnPrefix;
            final ZipInputStream zf = new ZipInputStream(new ByteArrayInputStream(zipFile));

            ZipEntry ze = null;
            while ((ze = zf.getNextEntry()) != null) {
                final String name = ze.getName();
                final long size = ze.getSize();

                // see if we are working with a file or a directory
                if (size != 0) {
                    byte[] fileContents = new byte[0];
                    final byte[] fileBuffer = new byte[BUFFER_SIZE];

                    int bytesRead = 0;
                    while ((bytesRead = zf.read(fileBuffer, 0, BUFFER_SIZE)) != -1) fileContents = ArrayUtils.addAll(fileContents,
                            bytesRead == BUFFER_SIZE ? fileBuffer : ArrayUtils.subarray(fileBuffer, 0, bytesRead));

                    output.put(fixedKeyPrefix + name.replace(fixedKeyUnPrefix, ""), fileContents);
                }
            }

        } catch (final IOException ex) {
           LOG.error("Unable to read file contents", ex);
        }
    }
571388
public static  PrivateKey loadPrivateKey(File file) { 
    	FileInputStream inputStream = null;
    	try {
    		inputStream = new FileInputStream(file);			
    		return loadPrivateKey(inputStream);
		} catch (FileNotFoundException e) {
			throw new RuntimeException("文件不存在");
		}finally {
			try {inputStream.close();} catch (Exception e2) {}
		}
    }
362361
public static NutMap checkPayReturn(String xml, String key) {
        try {
            NutMap map = Xmls.asMap(xmls().parse(new InputSource(new StringReader(xml))).getDocumentElement());
            return checkPayReturnMap(map, key);
        }
        catch (Exception e) {
            throw Lang.makeThrow("e.wx.pay.re.error : %s", xml);
        }
    }
1275370
public static XWPFDocument create(File file) {
		try {
			return FileUtil.exist(file) ? new XWPFDocument(OPCPackage.open(file)) : new XWPFDocument();
		} catch (InvalidFormatException e) {
			throw new POIException(e);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
670163
public String toEncryptedXml(WxCpConfigStorage wxCpConfigStorage) {
    String plainXml = toXml();
    WxCpCryptUtil pc = new WxCpCryptUtil(wxCpConfigStorage);
    return pc.encrypt(plainXml);
  }
1046601
@Sensitive
    public static byte[] getByteArrayPassword(@Sensitive String password) throws WIMSystemException {
        String METHODNAME = "getByteArrayPassword";
        try {
            if (password != null) {
                return password.getBytes("UTF-8");
            } else {
                return null;
            }
        } catch (java.io.UnsupportedEncodingException e) {
            if (tc.isErrorEnabled()) {
                Tr.error(tc, WIMMessageKey.GENERIC, WIMMessageHelper.generateMsgParms(e.toString()));
            }
            throw new WIMSystemException(WIMMessageKey.GENERIC, Tr.formatMessage(
                                                                                 tc,
                                                                                 WIMMessageKey.GENERIC,
                                                                                 WIMMessageHelper.generateMsgParms(e.toString())));
        }
    }
1196366
public static String sendGroupRedPack(Map<String, String> params, String certPath, String certPassword) {
		return HttpUtils.postSSL(sendGroupRedPackUrl, PaymentKit.toXml(params), certPath, certPassword);
	}
121128
public static String getGroupName(final File file) {
        if (OsValidator.WINDOWS) {
            logger.trace("Determining 'group' is skipped for file [{}] on [{}]", file, OsValidator.OS);
            return null;
        }
        try {
            final Path path = Paths.get(file.getAbsolutePath());
            final PosixFileAttributes posixFileAttributes = Files.getFileAttributeView(path, PosixFileAttributeView.class).readAttributes();
            return posixFileAttributes != null ? posixFileAttributes.group().getName() : null;
        } catch (Exception e) {
            logger.warn("Failed to determine 'group' of {}: {}", file, e.getMessage());
            return null;
        }
    }