Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:HEROLABS/herolabs-apns

Conflicts:
	src/herolabs/apns/feedback.clj
	src/herolabs/apns/protocol.clj
	src/herolabs/apns/push.clj
	src/herolabs/apns/ssl.clj
  • Loading branch information...
commit e38897706481aa50aa2a8a0dc1f3cbeff44dfdbf 2 parents be02ab7 + 54788e9
@niclasmeier niclasmeier authored
View
20 .gitignore
@@ -1,14 +1,12 @@
+/target
+/lib
+/classes
+/checkouts
pom.xml
-*jar
-*class
-*iml
-/lib/
-/classes/
-/newrelic/logs/
+*.jar
+*.class
.lein-deps-sum
.lein-failures
-/.idea/
-*.iml
-.project
-.classpath
-.settings/
+.lein-plugins
+.idea
+*.iml
View
18 src/herolabs/apns/feedback.clj
@@ -14,9 +14,7 @@
[java.util.concurrent Executors ExecutorService ThreadFactory]
[java.util.concurrent LinkedBlockingQueue TimeUnit]
[java.net InetSocketAddress]
- [javax.net.ssl SSLContext]
- )
- )
+ [javax.net.ssl SSLContext]))
(def ^:private default-thread-pool* (atom nil))
@@ -46,8 +44,8 @@
(channelConnected [^ChannelHandlerContext ctx ^ChannelStateEvent event]
(debug "channelConnected")
(let [^SslHandler ssl-handler (-> ctx
- (.getPipeline)
- (.get SslHandler))]
+ (.getPipeline)
+ (.get SslHandler))]
(.handshake ssl-handler)
))
(messageReceived [^ChannelHandlerContext ctx ^MessageEvent event]
@@ -57,8 +55,7 @@
(debug (.getCause event) "exceptionCaught")
(-> event
(.getChannel)
- (.close))
- )
+ (.close)))
(channelClosed [^ChannelHandlerContext ctx ^ChannelStateEvent event]
(debug "channelClosed"))))
@@ -93,10 +90,7 @@
channel
(do
(.releaseExternalResources bootstrap)
- nil
- )
- )
- )
+ nil)))
(catch java.lang.Exception e
(warn e "Error"))))
@@ -121,4 +115,4 @@
(defn dev-address [] (InetSocketAddress. "feedback.sandbox.push.apple.com" 2196))
-(defn prod-address [] (InetSocketAddress. "feedback.push.apple.com" 2196))
+(defn prod-address [] (InetSocketAddress. "feedback.push.apple.com" 2196))
View
22 src/herolabs/apns/message.clj
@@ -4,41 +4,33 @@
(defn with-badge [message number] (assoc-in message [:aps :badge ] number))
(defn with-sound [message sound]
- (assoc-in message [:aps :sound ] (name sound))
- )
+ (assoc-in message [:aps :sound ] (name sound)))
(defn with-standard-alert [message body]
- (assoc-in message [:aps :alert ] body)
- )
+ (assoc-in message [:aps :alert ] body))
(defn with-action-loc-key [message key]
(if key
(assoc-in message [:aps :alert :action-loc-key ] key)
- message)
- )
+ message))
(defn with-loc-key [message key]
(if key
(assoc-in message [:aps :alert :loc-key ] key)
- message)
- )
+ message))
(defn with-loc-args [message args]
(if-not (empty? args)
(assoc-in message [:aps :alert :loc-args ] (if (sequential? args) args (list args)))
- message)
- )
+ message))
(defn with-payload [message payload]
(if-not (empty? payload)
(merge (dissoc payload :aps) message)
- message)
- )
+ message))
(defn with-alert-body [message body]
(if key
(assoc-in message [:aps :alert :body ] body)
- message)
- )
-
+ message))
View
7 src/herolabs/apns/protocol.clj
@@ -4,8 +4,7 @@
[org.jboss.netty.buffer ChannelBuffer ChannelBuffers]
[java.nio ByteOrder]
[org.apache.commons.codec.binary Hex]
- [java.util.concurrent.atomic AtomicInteger]
- ))
+ [java.util.concurrent.atomic AtomicInteger]))
;; some constants
(def ^{:private true :tag 'bytes} standard-head (byte-array 1 (byte 0)))
@@ -19,8 +18,7 @@
(byte 5) :invalid-token-size
(byte 6) :invalid-topic-size
(byte 7) :invalid-payload-size
- (byte 8) :invalid-token
- })
+ (byte 8) :invalid-token})
(def ^:dynamic *coercions* json/*coercions*)
@@ -69,7 +67,6 @@
)
-
(defn encoder [^AtomicInteger id-gen]
"Creates an encoder for the APNS protocol"
(proxy [org.jboss.netty.handler.codec.oneone.OneToOneEncoder] []
View
14 src/herolabs/apns/push.clj
@@ -34,6 +34,7 @@
(when (not= Thread/NORM_PRIORITY (.getPriority t)) (.setPriority t Thread/NORM_PRIORITY))
t)))))))))
+
(def ^:private timer* (ref nil))
(defn- timer [] (or @timer* (dosync (alter timer* (fn [_] (HashedWheelTimer.))))))
@@ -54,22 +55,20 @@
(channelConnected [^ChannelHandlerContext ctx ^ChannelStateEvent event]
(trace "channelConnected")
(let [^SslHandler ssl-handler (-> ctx
- (.getPipeline)
- (.get SslHandler))]
+ (.getPipeline)
+ (.get SslHandler))]
(.handshake ssl-handler)
))
(channelDisconnected [^ChannelHandlerContext ctx ^ChannelStateEvent event]
(trace "channelDisconnected" this))
(messageReceived [^ChannelHandlerContext ctx ^MessageEvent event]
- (trace "messageReceived -" (.getMessage event))
- )
+ (trace "messageReceived -" (.getMessage event)))
(exceptionCaught [^ChannelHandlerContext ctx ^ExceptionEvent event]
(trace (.getCause event) "exceptionCaught")
(when exception-handler (exception-handler (.getCause event)))
(-> event
(.getChannel)
- (.close))
- )
+ (.close)))
(channelClosed [^ChannelHandlerContext ctx ^ChannelStateEvent event]
(trace "channelClosed")
(let [^SslHandler new-handler (ssl-handler-factory)
@@ -110,8 +109,7 @@
(.setPipelineFactory pipeline-factory)
(.setOption "remoteAddress" address))
future (.connect bootstrap)
- channel (-> future (.awaitUninterruptibly) (.getChannel))
- ]
+ channel (-> future (.awaitUninterruptibly) (.getChannel))]
(if (.isSuccess future)
(do
(swap! client-handle (fn [_] channel))
View
26 src/herolabs/apns/ssl.clj
@@ -5,8 +5,7 @@
(:import [org.apache.commons.codec.digest DigestUtils]
[java.security Security KeyStore]
[javax.net.ssl KeyManager KeyManagerFactory SSLContext SSLEngine TrustManager TrustManagerFactory X509TrustManager]
- [java.security.cert Certificate X509Certificate CertificateException CertificateFactory])
- )
+ [java.security.cert Certificate X509Certificate CertificateException CertificateFactory]))
(defn load-keystore
@@ -25,17 +24,14 @@
store-type "JCEKS"}}]
(let [keystore (if keystore keystore (load-keystore store-path store-pass store-type))
kmf (doto (KeyManagerFactory/getInstance algorithm)
- (.init keystore (char-array key-pass)))
+ (.init keystore (char-array key-pass)))
tms (if trust-managers trust-managers (.getTrustManagers (doto
(TrustManagerFactory/getInstance algorithm)
(.init ^KeyStore keystore)
)))
context (doto (SSLContext/getInstance "TLS")
- (.init (.getKeyManagers kmf) tms nil))
- ]
- context
- )
- )
+ (.init (.getKeyManagers kmf) tms nil))]
+ context))
(defn aliases [^KeyStore keystore]
(letfn [(get-aliases [^java.util.Enumeration enum] (lazy-seq
@@ -64,18 +60,14 @@
(let [^SSLEngine engine (.createSSLEngine context)]
(if use-client-mode
(doto engine (.setUseClientMode use-client-mode))
- engine)
- )
- )
+ engine)))
(defn ssl-engine-factory [^SSLContext context & {:keys [use-client-mode] :or {use-client-mode true}}]
"Creates an SSL engine"
(fn [] (let [engine (.createSSLEngine context)]
- (if use-client-mode
- (doto engine (.setUseClientMode use-client-mode))
- engine)
- )))
-
+ (if use-client-mode
+ (doto engine (.setUseClientMode use-client-mode))
+ engine))))
(defn naive-trust-managers [& {:keys [trace] :or [trace false]}]
@@ -87,4 +79,4 @@
(info "Unknown client certificate:" (.getSubjectDN ^X509Certificate (get chain 0)))))
(checkServerTrusted [ chain auth-type]
(when trace
- (info "Unknown server certificate:" (.getSubjectDN ^X509Certificate (get chain 0)))))))))
+ (info "Unknown server certificate:" (.getSubjectDN ^X509Certificate (get chain 0)))))))))
Please sign in to comment.
Something went wrong with that request. Please try again.