if (!ApnsUtil.checkValidity(iOSVariant.getCertificate(), iOSVariant.getPassphrase().toCharArray())) { senderCallback.onError("The provided certificate is invalid or expired for variant " + iOSVariant.getId()); final String defaultApnsTopic = ApnsUtil.readDefaultTopic(iOSVariant.getCertificate(), iOSVariant.getPassphrase().toCharArray()); logger.debug("sending payload for all tokens for {} to APNs ({})", iOSVariant.getVariantID(), defaultApnsTopic);
if (!ApnsUtil.checkValidity(iOSVariant.getCertificate(), iOSVariant.getPassphrase().toCharArray())) { senderCallback.onError("The provided certificate is invalid or expired for variant " + iOSVariant.getId()); final String defaultApnsTopic = ApnsUtil.readDefaultTopic(iOSVariant.getCertificate(), iOSVariant.getPassphrase().toCharArray()); logger.debug("sending payload for all tokens for {} to APNs ({})", iOSVariant.getVariantID(), defaultApnsTopic);
private ApnsClient buildApnsClient(final iOSVariant iOSVariant) { // this check should not be needed, but you never know: if (iOSVariant.getCertificate() != null && iOSVariant.getPassphrase() != null) { // add the certificate: try(final ByteArrayInputStream stream = new ByteArrayInputStream(iOSVariant.getCertificate())) { final ApnsClientBuilder builder = new ApnsClientBuilder(); builder.setClientCredentials(stream, iOSVariant.getPassphrase()); if (ProxyConfiguration.hasHttpProxyConfig()) { if (ProxyConfiguration.hasBasicAuth()) { String user = ProxyConfiguration.getProxyUser(); String pass = ProxyConfiguration.getProxyPass(); builder.setProxyHandlerFactory(new HttpProxyHandlerFactory(ProxyConfiguration.proxyAddress(), user, pass)); } else { builder.setProxyHandlerFactory(new HttpProxyHandlerFactory(ProxyConfiguration.proxyAddress())); } } else if (ProxyConfiguration.hasSocksProxyConfig()) { builder.setProxyHandlerFactory(new Socks5ProxyHandlerFactory(ProxyConfiguration.socks())); } final ApnsClient apnsClient = builder.build(); return apnsClient; } catch (Exception e) { logger.error("Error reading certificate", e); // will be thrown below } } // indicating an incomplete service throw new IllegalArgumentException("Not able to construct APNS client"); }
private ApnsClient buildApnsClient(final iOSVariant iOSVariant) { // this check should not be needed, but you never know: if (iOSVariant.getCertificate() != null && iOSVariant.getPassphrase() != null) { // add the certificate: try(final ByteArrayInputStream stream = new ByteArrayInputStream(iOSVariant.getCertificate())) { final ApnsClientBuilder builder = new ApnsClientBuilder(); builder.setClientCredentials(stream, iOSVariant.getPassphrase()); if (ProxyConfiguration.hasHttpProxyConfig()) { if (ProxyConfiguration.hasBasicAuth()) { String user = ProxyConfiguration.getProxyUser(); String pass = ProxyConfiguration.getProxyPass(); builder.setProxyHandlerFactory(new HttpProxyHandlerFactory(ProxyConfiguration.proxyAddress(), user, pass)); } else { builder.setProxyHandlerFactory(new HttpProxyHandlerFactory(ProxyConfiguration.proxyAddress())); } } else if (ProxyConfiguration.hasSocksProxyConfig()) { builder.setProxyHandlerFactory(new Socks5ProxyHandlerFactory(ProxyConfiguration.socks())); } final ApnsClient apnsClient = builder.build(); return apnsClient; } catch (Exception e) { logger.error("Error reading certificate", e); // will be thrown below } } // indicating an incomplete service throw new IllegalArgumentException("Not able to construct APNS client"); }