├── cloudsdk
├── .gitignore
├── consumer-proguard-rules.pro
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── services
│ │ │ │ ├── org.kaazing.net.ws.WebSocketFactory
│ │ │ │ ├── org.kaazing.net.sse.SseEventSourceFactory
│ │ │ │ ├── org.kaazing.net.auth.BasicChallengeHandler
│ │ │ │ ├── org.kaazing.net.auth.DispatchChallengeHandler
│ │ │ │ └── org.kaazing.net.URLStreamHandlerFactorySpi
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ ├── io
│ │ │ │ └── particle
│ │ │ │ │ └── android
│ │ │ │ │ └── sdk
│ │ │ │ │ ├── cloud
│ │ │ │ │ ├── SimpleParticleEventHandler.java
│ │ │ │ │ ├── ParticleEventHandler.java
│ │ │ │ │ ├── BroadcastContract.java
│ │ │ │ │ ├── FunctionArgs.java
│ │ │ │ │ ├── ParticleEventVisibility.java
│ │ │ │ │ ├── exceptions
│ │ │ │ │ │ ├── PartialDeviceListResultException.java
│ │ │ │ │ │ └── ParticleLoginException.java
│ │ │ │ │ ├── SDKGlobals.java
│ │ │ │ │ ├── ParticleEvent.java
│ │ │ │ │ ├── models
│ │ │ │ │ │ ├── DeviceStateChange.java
│ │ │ │ │ │ └── AccountInfo.java
│ │ │ │ │ ├── ParticleUser.java
│ │ │ │ │ └── ParticleCloudSDK.java
│ │ │ │ │ ├── utils
│ │ │ │ │ ├── Preconditions.java
│ │ │ │ │ ├── Toaster.java
│ │ │ │ │ ├── TLog.java
│ │ │ │ │ └── ParticleInternalStringUtils.java
│ │ │ │ │ └── persistance
│ │ │ │ │ └── AppDataStorage.java
│ │ │ └── org
│ │ │ │ └── kaazing
│ │ │ │ ├── net
│ │ │ │ ├── sse
│ │ │ │ │ ├── SseEventType.java
│ │ │ │ │ ├── impl
│ │ │ │ │ │ ├── SseEventStreamListener.java
│ │ │ │ │ │ ├── legacy
│ │ │ │ │ │ │ ├── EventSourceAdapter.java
│ │ │ │ │ │ │ ├── EventSourceListener.java
│ │ │ │ │ │ │ └── EventSourceEvent.java
│ │ │ │ │ │ ├── SsePayload.java
│ │ │ │ │ │ ├── url
│ │ │ │ │ │ │ └── SseURLStreamHandlerFactorySpiImpl.java
│ │ │ │ │ │ └── AuthenticatedEventSourceFactory.java
│ │ │ │ │ └── SseException.java
│ │ │ │ ├── ws
│ │ │ │ │ ├── WebSocketMessageType.java
│ │ │ │ │ ├── impl
│ │ │ │ │ │ ├── url
│ │ │ │ │ │ │ ├── WssURLStreamHandlerImpl.java
│ │ │ │ │ │ │ └── WssURLStreamHandlerFactorySpiImpl.java
│ │ │ │ │ │ ├── spi
│ │ │ │ │ │ │ ├── WebSocketExtensionSpi.java
│ │ │ │ │ │ │ └── WebSocketExtensionParameterValuesSpi.java
│ │ │ │ │ │ ├── WsExtensionParameterValuesSpiImpl.java
│ │ │ │ │ │ └── io
│ │ │ │ │ │ │ └── WsMessageWriterImpl.java
│ │ │ │ │ └── WebSocketMessageWriter.java
│ │ │ │ ├── impl
│ │ │ │ │ └── auth
│ │ │ │ │ │ ├── BasicChallengeResponseFactory.java
│ │ │ │ │ │ └── RealmUtils.java
│ │ │ │ ├── auth
│ │ │ │ │ └── LoginHandler.java
│ │ │ │ └── URLStreamHandlerFactorySpi.java
│ │ │ │ └── gateway
│ │ │ │ ├── bridge
│ │ │ │ └── ValidateOrigin.java
│ │ │ │ └── client
│ │ │ │ ├── impl
│ │ │ │ ├── CommandMessage.java
│ │ │ │ ├── Handler.java
│ │ │ │ ├── wseb
│ │ │ │ │ ├── CreateHandlerFactory.java
│ │ │ │ │ ├── UpstreamHandlerFactory.java
│ │ │ │ │ ├── DownstreamHandlerFactory.java
│ │ │ │ │ ├── UpstreamHandlerListener.java
│ │ │ │ │ ├── WebSocketEmulatedDecoder.java
│ │ │ │ │ ├── CreateHandlerListener.java
│ │ │ │ │ ├── WebSocketEmulatedEncoder.java
│ │ │ │ │ ├── WebSocketEmulatedDecoderListener.java
│ │ │ │ │ ├── CreateHandler.java
│ │ │ │ │ ├── DownstreamHandler.java
│ │ │ │ │ ├── UpstreamHandler.java
│ │ │ │ │ ├── DownstreamHandlerListener.java
│ │ │ │ │ ├── WebSocketEmulatedChannel.java
│ │ │ │ │ ├── CreateChannel.java
│ │ │ │ │ └── UpstreamChannel.java
│ │ │ │ ├── WebSocketHandlerFactory.java
│ │ │ │ ├── http
│ │ │ │ │ ├── HttpRequestHandlerFactory.java
│ │ │ │ │ ├── HttpRequestFactory.java
│ │ │ │ │ ├── HttpRequestHandler.java
│ │ │ │ │ ├── HttpRequestListener.java
│ │ │ │ │ └── HttpRequestEvent.java
│ │ │ │ ├── ws
│ │ │ │ │ ├── ReadyState.java
│ │ │ │ │ ├── WebSocketSelectedHandler.java
│ │ │ │ │ ├── WebSocketSelectedChannel.java
│ │ │ │ │ ├── CloseCommandMessage.java
│ │ │ │ │ └── WebSocketHandshakeObject.java
│ │ │ │ ├── DecoderInput.java
│ │ │ │ ├── EncoderOutput.java
│ │ │ │ ├── bridge
│ │ │ │ │ ├── ProxyListener.java
│ │ │ │ │ ├── ClassLoaderFactory.java
│ │ │ │ │ └── Proxy.java
│ │ │ │ ├── DecoderListener.java
│ │ │ │ ├── wsn
│ │ │ │ │ ├── WebSocketNativeEncoder.java
│ │ │ │ │ └── WebSocketNativeChannel.java
│ │ │ │ ├── WebSocketHandler.java
│ │ │ │ ├── Channel.java
│ │ │ │ └── util
│ │ │ │ │ └── WSURI.java
│ │ │ │ ├── transport
│ │ │ │ ├── BridgeDelegate.java
│ │ │ │ ├── http
│ │ │ │ │ ├── HttpRequestDelegateFactory.java
│ │ │ │ │ ├── HttpRequestDelegate.java
│ │ │ │ │ └── HttpRequestDelegateListener.java
│ │ │ │ ├── ws
│ │ │ │ │ ├── BridgeSocketFactory.java
│ │ │ │ │ ├── FrameProcessorListener.java
│ │ │ │ │ ├── WebSocketDelegateFactory.java
│ │ │ │ │ ├── BridgeSocket.java
│ │ │ │ │ ├── WebSocketDelegate.java
│ │ │ │ │ ├── WebSocketDelegateListener.java
│ │ │ │ │ ├── WsMessage.java
│ │ │ │ │ └── BridgeSocketImpl.java
│ │ │ │ ├── ReadyStateChangedEvent.java
│ │ │ │ ├── ErrorEvent.java
│ │ │ │ ├── CloseEvent.java
│ │ │ │ ├── LoadEvent.java
│ │ │ │ ├── RedirectEvent.java
│ │ │ │ ├── AuthenticateEvent.java
│ │ │ │ ├── OpenEvent.java
│ │ │ │ ├── IoBufferUtil.java
│ │ │ │ ├── ProgressEvent.java
│ │ │ │ └── Event.java
│ │ │ │ └── util
│ │ │ │ ├── auth
│ │ │ │ └── LoginHandlerProvider.java
│ │ │ │ ├── HttpURI.java
│ │ │ │ └── URIUtils.java
│ │ └── res
│ │ │ └── values
│ │ │ ├── oauth_client_creds.xml
│ │ │ └── config.xml
│ └── androidTest
│ │ └── java
│ │ └── io
│ │ └── particle
│ │ └── android
│ │ └── sdk
│ │ └── cloud
│ │ └── ApplicationTest.java
└── proguard-rules.pro
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── example_app
├── src
│ └── main
│ │ ├── res
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── values
│ │ │ ├── styles.xml
│ │ │ ├── dimens.xml
│ │ │ └── strings.xml
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ ├── menu
│ │ │ ├── menu_splash.xml
│ │ │ └── menu_value.xml
│ │ └── layout
│ │ │ ├── activity_splash.xml
│ │ │ ├── activity_value.xml
│ │ │ └── activity_login.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── io
│ │ └── particle
│ │ └── cloudsdk
│ │ └── example_app
│ │ └── SplashActivity.java
├── proguard-rules.pro
└── build.gradle
├── README.md
├── RELEASE.md
├── .gitignore
├── gradle.properties
├── pom_generator_v1.gradle
├── .idea
└── codeStyles
│ └── Project.xml
├── bintray_upload_v1.gradle
├── CHANGELOG
└── gradlew.bat
/cloudsdk/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/cloudsdk/consumer-proguard-rules.pro:
--------------------------------------------------------------------------------
1 | -dontwarn okio.**
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':cloudsdk'
2 | include ':example_app'
3 |
4 |
--------------------------------------------------------------------------------
/cloudsdk/src/main/resources/META-INF/services/org.kaazing.net.ws.WebSocketFactory:
--------------------------------------------------------------------------------
1 | org.kaazing.net.ws.impl.DefaultWebSocketFactory
--------------------------------------------------------------------------------
/cloudsdk/src/main/resources/META-INF/services/org.kaazing.net.sse.SseEventSourceFactory:
--------------------------------------------------------------------------------
1 | org.kaazing.net.sse.impl.DefaultEventSourceFactory
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/particle-iot-archived/spark-sdk-android/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/cloudsdk/src/main/resources/META-INF/services/org.kaazing.net.auth.BasicChallengeHandler:
--------------------------------------------------------------------------------
1 | org.kaazing.net.impl.auth.DefaultBasicChallengeHandler
2 |
--------------------------------------------------------------------------------
/cloudsdk/src/main/resources/META-INF/services/org.kaazing.net.auth.DispatchChallengeHandler:
--------------------------------------------------------------------------------
1 | org.kaazing.net.impl.auth.DefaultDispatchChallengeHandler
2 |
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/particle-iot-archived/spark-sdk-android/HEAD/example_app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/particle-iot-archived/spark-sdk-android/HEAD/example_app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/particle-iot-archived/spark-sdk-android/HEAD/example_app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example_app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/particle-iot-archived/spark-sdk-android/HEAD/example_app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/cloudsdk/src/main/resources/META-INF/services/org.kaazing.net.URLStreamHandlerFactorySpi:
--------------------------------------------------------------------------------
1 | org.kaazing.net.ws.impl.url.WsURLStreamHandlerFactorySpiImpl
2 | org.kaazing.net.ws.impl.url.WssURLStreamHandlerFactorySpiImpl
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Particle Android Cloud SDK
2 |
3 | ## MOVED!
4 |
5 | The Cloud SDK has moved to [the new Particle Android repository!](https://github.com/particle-iot/particle-android) This repository is now deprecated and will not be updated.
6 |
7 |
--------------------------------------------------------------------------------
/cloudsdk/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
29 | * A WebSocket Extension implementation consists of the following: 30 | *
37 | * Every supported extension will require implementing the aforementioned 38 | * classes. A subset of the supported extensions will be enabled by the 39 | * application developer. 40 | *
41 | * The enabled extensions are included on the wire during the handshake for 42 | * the client and the server to negotiate. 43 | *
44 | * The successfully negotiated extensions are then added to the WebSocket
45 | * message processing pipeline.
46 | *
47 | * @see RevalidateExtension
48 | */
49 | public abstract class WebSocketExtensionSpi {
50 |
51 | public abstract WebSocketExtensionHandlerSpi createHandler();
52 | }
53 |
--------------------------------------------------------------------------------
/cloudsdk/src/main/java/org/kaazing/gateway/client/impl/http/HttpRequestListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2007-2014 Kaazing Corporation. All rights reserved.
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package org.kaazing.gateway.client.impl.http;
23 |
24 | import org.kaazing.gateway.client.util.WrappedByteBuffer;
25 |
26 | public interface HttpRequestListener {
27 |
28 | /** Invoked when the request is ready to send data upstream */
29 | void requestReady(HttpRequest request);
30 |
31 | /** Invoked when the response status code and headers are available */
32 | void requestOpened(HttpRequest request);
33 |
34 | /** Invoked when streamed data is received on the response */
35 | void requestProgressed(HttpRequest request, WrappedByteBuffer payload);
36 |
37 | /** Invoked when the response has completed and all data is available */
38 | void requestLoaded(HttpRequest request, HttpResponse response);
39 |
40 | /** Invoked when the request has been aborted */
41 | void requestAborted(HttpRequest request);
42 |
43 | /** Invoked when the request has closed and no longer valid */
44 | void requestClosed(HttpRequest request);
45 |
46 | /** Invoked when an error has occurred while processing the request or response */
47 | void errorOccurred(HttpRequest request, Exception exception);
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/cloudsdk/src/main/java/org/kaazing/gateway/client/impl/Channel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2007-2014 Kaazing Corporation. All rights reserved.
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package org.kaazing.gateway.client.impl;
23 |
24 | import org.kaazing.net.auth.ChallengeResponse;
25 |
26 | import java.util.concurrent.atomic.AtomicLong;
27 |
28 | public class Channel {
29 | public static final String HEADER_SEQUENCE = "X-Sequence-No";
30 |
31 | // TODO: This is an abstration violation - authentication should not be exposed on Channel
32 | /** Authentication data */
33 | public ChallengeResponse challengeResponse = new ChallengeResponse(null, null);
34 | public boolean authenticationReceived = false;
35 | public boolean preventFallback = false;
36 |
37 | private Channel parent;
38 | private final AtomicLong sequence;
39 |
40 | public Channel() {
41 | this(0);
42 | }
43 |
44 | public Channel(long sequence) {
45 | this.sequence = new AtomicLong(sequence);
46 | }
47 |
48 | public void setParent(Channel parent) {
49 | this.parent = parent;
50 | }
51 |
52 | public Channel getParent() {
53 | return parent;
54 | }
55 |
56 | public long nextSequence() {
57 | return this.sequence.getAndIncrement();
58 | }
59 |
60 | @Override
61 | public String toString() {
62 | return "[" + this.getClass().getSimpleName() + "]";
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/cloudsdk/src/main/java/org/kaazing/gateway/client/transport/OpenEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2007-2014 Kaazing Corporation. All rights reserved.
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package org.kaazing.gateway.client.transport;
23 |
24 | import java.util.logging.Logger;
25 |
26 | public class OpenEvent extends Event {
27 | private static final String CLASS_NAME = OpenEvent.class.getName();
28 | private static final Logger LOG = Logger.getLogger(CLASS_NAME);
29 |
30 | private String protocol;
31 |
32 | public OpenEvent() {
33 | super(Event.OPEN);
34 | LOG.entering(CLASS_NAME, "
32 | * {@link URLStreamHandlerFactory} is a singleton that is registered using the
33 | * static method
34 | * {@link URL#setURLStreamHandlerFactory(URLStreamHandlerFactory)}. Also,
35 | * the {@link URL} objects can only be created for the following protocols:
36 | * -- http, https, file, ftp, and jar. In order to install protocol handlers
37 | * for other protocols, one has to hijack or override the system's singleton
38 | * {@link URLStreamHandlerFactory} instance with a custom implementation. The
39 | * objective of this class is to make the {@link URLStreamHandler} registration
40 | * for other protocols such as ws, wss, etc. feasible without hijacking the
41 | * system's {@link URLStreamHandlerFactory}.
42 | *
43 | */
44 | public abstract class URLStreamHandlerFactorySpi implements URLStreamHandlerFactory {
45 |
46 | /**
47 | * Returns a list of supported protocols. This can be used to instantiate
48 | * appropriate {@link URLStreamHandler} objects based on the protocol.
49 | *
50 | * @return list of supported protocols
51 | */
52 | public abstract Collection
34 | * WsExtensionParameterValues is used to cache extension parameters as
35 | * name-value pairs in a very generic type-safe way. The implementations of
36 | * {@link WebSocket#connect()} and {@link WsURLConnection#connect()} invoke
37 | * {@link WebSocketExtensionFactorySpi#createWsExtension(WebSocketExtensionParameterValuesSpi)}
38 | * method and pass in all the extension parameters that have been earlier set
39 | * by the developer for the enabled extensions.
40 | */
41 | public abstract class WebSocketExtensionParameterValuesSpi {
42 | /**
43 | * Returns the collection of {@link Parameter} objects of a
44 | * {@link WebSocketExtension} that have been set. Returns an empty
45 | * Collection if no parameters belonging to the extension have been set.
46 | *
47 | * @return Collection
35 | * Once the connection is closed, a new {@link WebSocketMessageReader} should
36 | * be obtained using the aforementioned methods after the connection has been
37 | * established. Using the old reader will result in IOException.
38 | */
39 | public abstract class WebSocketMessageWriter {
40 |
41 | /**
42 | * Sends a text message using the specified payload. Trying to write
43 | * after the underlying connection has been closed will result in an
44 | * IOException.
45 | *
46 | * @param src CharSequence payload of the message
47 | * @throws IOException if the connection is not open or if the connection
48 | * has been closed
49 | */
50 | public abstract void writeText(CharSequence src) throws IOException;
51 |
52 | /**
53 | * Sends a binary message using the specified payload.
54 | *
55 | * @param src ByteBuffer payload of the message
56 | * @throws IOException if the connection is not open or if the connection
57 | * has been closed
58 | */
59 | public abstract void writeBinary(ByteBuffer src) throws IOException;
60 | }
61 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/cloudsdk/src/main/java/org/kaazing/net/ws/impl/io/WsMessageWriterImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2007-2014 Kaazing Corporation. All rights reserved.
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package org.kaazing.net.ws.impl.io;
23 |
24 | import org.kaazing.net.ws.WebSocketException;
25 | import org.kaazing.net.ws.WebSocketMessageWriter;
26 | import org.kaazing.net.ws.impl.WebSocketImpl;
27 |
28 | import java.io.IOException;
29 | import java.io.UnsupportedEncodingException;
30 | import java.nio.ByteBuffer;
31 |
32 | public class WsMessageWriterImpl extends WebSocketMessageWriter {
33 | private WebSocketImpl _webSocket;
34 | private boolean _closed = false;
35 |
36 | public WsMessageWriterImpl(WebSocketImpl webSocket) {
37 | _webSocket = webSocket;
38 | }
39 |
40 | @Override
41 | public void writeText(CharSequence src) throws IOException {
42 | if (isClosed()) {
43 | String s = "Cannot write as the MessageWriter is closed";
44 | throw new WebSocketException(s);
45 | }
46 | try {
47 | src.toString().getBytes("UTF-8");
48 | }
49 | catch (UnsupportedEncodingException e) {
50 | String s = "The platform must support UTF-8 encoded text per RFC 6455";
51 | throw new IOException(s);
52 | }
53 |
54 | _webSocket.send(src.toString());
55 | }
56 |
57 | @Override
58 | public void writeBinary(ByteBuffer src) throws IOException {
59 | if (isClosed()) {
60 | String s = "Cannot write as the MessageWriter is closed";
61 | throw new WebSocketException(s);
62 | }
63 |
64 | _webSocket.send(src);
65 | }
66 |
67 | // ----------------- Internal Implementation ----------------------------
68 | public void close() {
69 | _closed = true;
70 | _webSocket = null;
71 | }
72 |
73 | public boolean isClosed() {
74 | return _closed;
75 | }
76 | }
--------------------------------------------------------------------------------
/cloudsdk/src/main/java/org/kaazing/net/impl/auth/RealmUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2007-2014 Kaazing Corporation. All rights reserved.
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package org.kaazing.net.impl.auth;
23 |
24 | import org.kaazing.net.auth.ChallengeRequest;
25 |
26 | import java.util.regex.Matcher;
27 | import java.util.regex.Pattern;
28 |
29 | public final class RealmUtils {
30 |
31 | private RealmUtils() {
32 | // prevent object creation
33 | }
34 |
35 | private static final String REALM_REGEX = "(.*)\\s?(?i:realm=)(\"(.*)\")(.*)";
36 | private static final Pattern REALM_PATTERN= Pattern.compile(REALM_REGEX);
37 |
38 | /**
39 | * A realm parameter is a valid authentication parameter for all authentication schemes
40 | * according to RFC 2617 Section 2.1".
41 | *
42 | *
36 | * {@code
37 | *
38 | * BasicChallengeHandler basicChallengeHandler = ChallengeHandlerLoader.load(BasicChallengeHandler.class);
39 | * LoginHandler loginHandler = new LoginHandler() {
40 | * public PasswordAuthentication getCredentials() {
41 | * // Obtain credentials in an application-specific manner
42 | * }
43 | * }
44 | * basicChallengeHandler.setLoginHandler(loginHandler);
45 | *
46 | * }
47 | *
48 | */
49 | public abstract class LoginHandler {
50 |
51 | /**
52 | * Default constructor.
53 | */
54 | protected LoginHandler() {
55 | }
56 |
57 | /**
58 | * Gets the password authentication credentials from an arbitrary source.
59 | * @return the password authentication obtained.
60 | */
61 | public abstract PasswordAuthentication getCredentials();
62 |
63 | }
--------------------------------------------------------------------------------
/cloudsdk/src/main/java/org/kaazing/gateway/client/impl/ws/WebSocketHandshakeObject.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2007-2014 Kaazing Corporation. All rights reserved.
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package org.kaazing.gateway.client.impl.ws;
23 |
24 | public class WebSocketHandshakeObject {
25 |
26 | private String name;
27 | private String escape;
28 | private HandshakeStatus status;
29 |
30 | /**
31 | * @return the name
32 | */
33 | public String getName() {
34 | return name;
35 | }
36 |
37 | /**
38 | * @param name the name to set
39 | */
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 |
44 | /**
45 | * @return the escape
46 | */
47 | public String getEscape() {
48 | return escape;
49 | }
50 |
51 | /**
52 | * @param escape the escape to set
53 | */
54 | public void setEscape(String escape) {
55 | this.escape = escape;
56 | }
57 |
58 | /**
59 | * @return the status
60 | */
61 | public HandshakeStatus getStatus() {
62 | return status;
63 | }
64 |
65 | /**
66 | * @param status the status to set
67 | */
68 | public void setStatus(HandshakeStatus status) {
69 | this.status = status;
70 | }
71 |
72 | public enum HandshakeStatus {
73 | Pending,
74 | Accepted
75 | }
76 |
77 | /* Kaazing default objects */
78 | public final static String KAAZING_EXTENDED_HANDSHAKE = "x-kaazing-handshake";
79 | public static final String KAAZING_SEC_EXTENSION_IDLETIMEOUT = "x-kaazing-idle-timeout";
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/cloudsdk/src/main/java/org/kaazing/gateway/client/impl/util/WSURI.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2007-2014 Kaazing Corporation. All rights reserved.
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package org.kaazing.gateway.client.impl.util;
23 |
24 | import org.kaazing.gateway.client.util.GenericURI;
25 | import org.kaazing.gateway.client.util.URIUtils;
26 |
27 | import java.net.URI;
28 | import java.net.URISyntaxException;
29 |
30 |
31 | /**
32 | * URI with guarantee to be a valid, non-null, ws URI
33 | */
34 | public class WSURI extends GenericURI
43 | * The realm directive (case-insensitive) is required for all
44 | * authentication schemes that issue a challenge. The realm value
45 | * (case-sensitive), in combination with the canonical root URL (the
46 | * absoluteURI for the server whose abs_path is empty) of the server
47 | * being accessed, defines the protection space.
48 | *
49 | *
50 | * @param challengeRequest the challenge request to extract a realm from
51 | *
52 | * @return the unquoted realm parameter value if present, or {@code null} if no such parameter exists.
53 | */
54 | public static String getRealm(ChallengeRequest challengeRequest) {
55 | String authenticationParameters = challengeRequest.getAuthenticationParameters();
56 | if ( authenticationParameters == null) {
57 | return null;
58 | }
59 | Matcher m = REALM_PATTERN.matcher(authenticationParameters);
60 | if ( m.matches() && m.groupCount()>=3) {
61 | return m.group(3);
62 | }
63 | return null;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/cloudsdk/src/main/java/io/particle/android/sdk/cloud/ParticleCloudSDK.java:
--------------------------------------------------------------------------------
1 | package io.particle.android.sdk.cloud;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.Nullable;
5 |
6 | import javax.annotation.ParametersAreNonnullByDefault;
7 |
8 | import io.particle.android.sdk.cloud.ApiFactory.OauthBasicAuthCredentialsProvider;
9 | import io.particle.android.sdk.utils.TLog;
10 |
11 | /**
12 | * Entry point for the Particle Cloud SDK.
13 | */
14 | @ParametersAreNonnullByDefault
15 | public class ParticleCloudSDK {
16 | // NOTE: pay attention to the interface, try to ignore the implementation, it's going to change.
17 |
18 | /**
19 | * Initialize the cloud SDK. Must be called somewhere in your Application.onCreate()
20 | *
21 | * (or anywhere else before your first Activity.onCreate() is called)
22 | */
23 | public static void init(Context ctx) {
24 | initWithParams(ctx, null);
25 | }
26 |
27 | public static void initWithOauthCredentialsProvider(
28 | Context ctx, @Nullable OauthBasicAuthCredentialsProvider oauthProvider) {
29 | initWithParams(ctx, oauthProvider);
30 | }
31 |
32 | public static ParticleCloud getCloud() {
33 | verifyInitCalled();
34 | return instance.sdkProvider.getParticleCloud();
35 | }
36 |
37 |
38 | // NOTE: This is closer to the interface I'd like to provide eventually
39 | static void initWithParams(Context ctx,
40 | @Nullable OauthBasicAuthCredentialsProvider oauthProvider) {
41 | if (instance != null) {
42 | log.w("Calling ParticleCloudSDK.init() more than once does not re-initialize the SDK.");
43 | return;
44 | }
45 |
46 | Context appContext = ctx.getApplicationContext();
47 | SDKProvider sdkProvider = new SDKProvider(appContext, oauthProvider);
48 | instance = new ParticleCloudSDK(sdkProvider);
49 | }
50 |
51 | @SuppressWarnings("BooleanMethodIsAlwaysInverted")
52 | static boolean isInitialized() {
53 | return instance != null;
54 | }
55 |
56 | static SDKProvider getSdkProvider() {
57 | verifyInitCalled();
58 | return instance.sdkProvider;
59 | }
60 |
61 | static void verifyInitCalled() {
62 | if (!isInitialized()) {
63 | throw new IllegalStateException("init not called before using the Particle SDK. "
64 | + "Are you calling ParticleCloudSDK.init() in your Application.onCreate()?");
65 | }
66 | }
67 |
68 |
69 | private static final TLog log = TLog.get(ParticleCloudSDK.class);
70 |
71 | private static ParticleCloudSDK instance;
72 |
73 |
74 | private final SDKProvider sdkProvider;
75 |
76 | private ParticleCloudSDK(SDKProvider sdkProvider) {
77 | this.sdkProvider = sdkProvider;
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/cloudsdk/src/main/java/io/particle/android/sdk/cloud/models/AccountInfo.java:
--------------------------------------------------------------------------------
1 | package io.particle.android.sdk.cloud.models;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import com.google.gson.annotations.SerializedName;
7 |
8 | /**
9 | * Keeps secondary user account information.
10 | */
11 | public class AccountInfo implements Parcelable {
12 | @SerializedName("first_name")
13 | private String firstName;
14 | @SerializedName("last_name")
15 | private String lastName;
16 | @SerializedName("company_name")
17 | private String companyName;
18 | @SerializedName("business_account")
19 | private boolean businessAccount;
20 |
21 | public AccountInfo() {
22 | }
23 |
24 | public AccountInfo(String firstName, String lastName, String companyName, boolean businessAccount) {
25 | this.firstName = firstName;
26 | this.lastName = lastName;
27 | this.companyName = companyName;
28 | this.businessAccount = businessAccount;
29 | }
30 |
31 | public String getFirstName() {
32 | return firstName;
33 | }
34 |
35 | public void setFirstName(String firstName) {
36 | this.firstName = firstName;
37 | }
38 |
39 | public String getLastName() {
40 | return lastName;
41 | }
42 |
43 | public void setLastName(String lastName) {
44 | this.lastName = lastName;
45 | }
46 |
47 | public String getCompanyName() {
48 | return companyName;
49 | }
50 |
51 | public void setCompanyName(String companyName) {
52 | this.companyName = companyName;
53 | }
54 |
55 | public boolean isBusinessAccount() {
56 | return businessAccount;
57 | }
58 |
59 | public void setBusinessAccount(boolean isBusinessAccount) {
60 | this.businessAccount = isBusinessAccount;
61 | }
62 |
63 | @Override
64 | public int describeContents() {
65 | return 0;
66 | }
67 |
68 | @Override
69 | public void writeToParcel(Parcel dest, int flags) {
70 | dest.writeString(this.firstName);
71 | dest.writeString(this.lastName);
72 | dest.writeString(this.companyName);
73 | dest.writeByte(this.businessAccount ? (byte) 1 : (byte) 0);
74 | }
75 |
76 | protected AccountInfo(Parcel in) {
77 | this.firstName = in.readString();
78 | this.lastName = in.readString();
79 | this.companyName = in.readString();
80 | this.businessAccount = in.readByte() != 0;
81 | }
82 |
83 | public static final Creator