├── .gitignore ├── src ├── main │ └── java │ │ └── com │ │ └── seleniumgrid2api │ │ ├── StartGrid.java │ │ ├── api │ │ ├── GridInfo.java │ │ └── GridInfoExtractor.java │ │ └── servlet │ │ ├── AllProxiesJsonServlet.java │ │ └── ProxyStatusJsonServlet.java └── test │ └── java │ └── com │ └── seleniumgrid2api │ └── GetNodeDetails.java ├── pom.xml ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | .idea/ 3 | *.iml 4 | # Package Files # 5 | *.jar 6 | *.war 7 | *.ear 8 | -------------------------------------------------------------------------------- /src/main/java/com/seleniumgrid2api/StartGrid.java: -------------------------------------------------------------------------------- 1 | package com.seleniumgrid2api; 2 | 3 | import org.openqa.grid.selenium.GridLauncher; 4 | 5 | public class StartGrid { 6 | 7 | public static void main(String[] args) throws Exception { 8 | String[] a = {"-port", "4444", 9 | "-host", "localhost", 10 | "-role", "hub", 11 | "-servlets", "com.seleniumgrid2api.servlet.AllProxiesJsonServlet,com.seleniumgrid2api.servlet.ProxyStatusJsonServlet" }; 12 | GridLauncher.main(a); 13 | } 14 | } -------------------------------------------------------------------------------- /src/test/java/com/seleniumgrid2api/GetNodeDetails.java: -------------------------------------------------------------------------------- 1 | package com.seleniumgrid2api; 2 | 3 | import com.seleniumgrid2api.api.GridInfo; 4 | import com.seleniumgrid2api.api.GridInfoExtractor; 5 | import org.junit.Test; 6 | import org.openqa.selenium.WebDriver; 7 | import org.openqa.selenium.remote.DesiredCapabilities; 8 | import org.openqa.selenium.remote.RemoteWebDriver; 9 | 10 | import java.net.URL; 11 | 12 | public class GetNodeDetails { 13 | 14 | @Test 15 | public void getNodeDetailsViaTestSession() throws Exception { 16 | 17 | DesiredCapabilities capability = DesiredCapabilities.firefox(); 18 | 19 | URL hub = new URL("http://localhost:4444/wd/hub"); 20 | 21 | WebDriver driver = new RemoteWebDriver(hub, capability); 22 | 23 | System.out.println("Session Id: " + ((RemoteWebDriver) driver).getSessionId()); 24 | 25 | GridInfo gridInfo = GridInfoExtractor.getHostNameAndPort(hub.getHost(), hub.getPort(), ((RemoteWebDriver) driver).getSessionId()); 26 | 27 | System.out.println("I'm running on: " + gridInfo.getHost() + ":" + gridInfo.getPort()); 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | selenium-grid2-api 8 | selenium-grid2-api 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | org.seleniumhq.selenium 14 | selenium-server 15 | 2.32.0 16 | 17 | 18 | junit 19 | junit 20 | 4.11 21 | 22 | 23 | commons-io 24 | commons-io 25 | 2.4 26 | 27 | 28 | org.apache.httpcomponents 29 | httpclient 30 | 4.2.5 31 | 32 | 33 | org.apache.httpcomponents 34 | httpcore 35 | 4.2.4 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/java/com/seleniumgrid2api/api/GridInfo.java: -------------------------------------------------------------------------------- 1 | package com.seleniumgrid2api.api; 2 | 3 | import org.json.JSONException; 4 | import org.json.JSONObject; 5 | 6 | import java.net.MalformedURLException; 7 | import java.net.URL; 8 | 9 | 10 | public class GridInfo { 11 | 12 | private URL proxyId; 13 | private String host; 14 | private int port; 15 | private String internalKey; 16 | private String session; 17 | private String inactivityTime; 18 | private String msg; 19 | private String success; 20 | 21 | public URL getProxyId() { 22 | return proxyId; 23 | } 24 | 25 | public String getHost() { 26 | return host; 27 | } 28 | 29 | public int getPort() { 30 | return port; 31 | } 32 | 33 | public String getInternalKey() { 34 | return internalKey; 35 | } 36 | 37 | public String getSession() { 38 | return session; 39 | } 40 | 41 | public String getInactivityTime() { 42 | return inactivityTime; 43 | } 44 | 45 | public String getMsg() { 46 | return msg; 47 | } 48 | 49 | public String getSuccess() { 50 | return success; 51 | } 52 | 53 | public GridInfo(JSONObject object) { 54 | try { 55 | proxyId = new URL(object.getString("proxyId")); 56 | if ((proxyId.getHost() != null) && (proxyId.getPort() != -1)) { 57 | host = proxyId.getHost(); 58 | port = proxyId.getPort(); 59 | } 60 | internalKey = object.getString("internalKey"); 61 | session = object.getString("session"); 62 | inactivityTime = object.getString("inactivityTime"); 63 | msg = object.getString("msg"); 64 | success = object.getString("success"); 65 | 66 | } catch (MalformedURLException | JSONException e) { 67 | System.out.println("Error Parsing Grid Info."); 68 | } 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/seleniumgrid2api/api/GridInfoExtractor.java: -------------------------------------------------------------------------------- 1 | package com.seleniumgrid2api.api; 2 | 3 | import org.apache.http.HttpHost; 4 | import org.apache.http.HttpResponse; 5 | import org.apache.http.HttpStatus; 6 | import org.apache.http.impl.client.DefaultHttpClient; 7 | import org.apache.http.message.BasicHttpEntityEnclosingRequest; 8 | import org.json.JSONException; 9 | import org.json.JSONObject; 10 | import org.openqa.selenium.remote.SessionId; 11 | 12 | import java.io.BufferedReader; 13 | import java.io.IOException; 14 | import java.io.InputStreamReader; 15 | import java.net.URL; 16 | 17 | public final class GridInfoExtractor { 18 | 19 | private GridInfoExtractor() { 20 | } 21 | 22 | public static GridInfo getHostNameAndPort(String hubHost, int hubPort, SessionId session) { 23 | 24 | GridInfo retVal = null; 25 | 26 | try { 27 | HttpHost host = new HttpHost(hubHost, hubPort); 28 | DefaultHttpClient client = new DefaultHttpClient(); 29 | URL sessionURL = new URL("http://" + hubHost + ":" + hubPort + "/grid/api/testsession?session=" + session); 30 | BasicHttpEntityEnclosingRequest basicHttpEntityEnclosingRequest = new BasicHttpEntityEnclosingRequest("POST", sessionURL.toExternalForm()); 31 | HttpResponse response = client.execute(host, basicHttpEntityEnclosingRequest); 32 | if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { 33 | JSONObject object = extractObject(response); 34 | retVal = new GridInfo(object); 35 | } else { 36 | System.out.println("Problem connecting to Grid Server"); 37 | } 38 | } catch (JSONException | IOException e) { 39 | throw new RuntimeException("Failed to acquire remote webdriver node and port info", e); 40 | } 41 | return retVal; 42 | } 43 | 44 | private static JSONObject extractObject(HttpResponse resp) throws IOException, JSONException { 45 | try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()))) { 46 | StringBuilder stringBuilder = new StringBuilder(); 47 | String line; 48 | while ((line = bufferedReader.readLine()) != null) { 49 | stringBuilder.append(line); 50 | } 51 | bufferedReader.close(); 52 | return new JSONObject(stringBuilder.toString()); 53 | } catch (Exception e) { 54 | System.out.println("error" + e.toString()); 55 | } 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/seleniumgrid2api/servlet/AllProxiesJsonServlet.java: -------------------------------------------------------------------------------- 1 | package com.seleniumgrid2api.servlet; 2 | 3 | 4 | import org.json.JSONArray; 5 | import org.json.JSONException; 6 | import org.json.JSONObject; 7 | import org.openqa.grid.common.exception.GridException; 8 | import org.openqa.grid.internal.ProxySet; 9 | import org.openqa.grid.internal.Registry; 10 | import org.openqa.grid.internal.RemoteProxy; 11 | import org.openqa.grid.web.servlet.RegistryBasedServlet; 12 | 13 | import javax.servlet.ServletException; 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | import java.io.IOException; 17 | import java.util.Iterator; 18 | 19 | public class AllProxiesJsonServlet extends RegistryBasedServlet { 20 | 21 | private static final long serialVersionUID = -1975392591408983229L; 22 | 23 | public AllProxiesJsonServlet() { 24 | this(null); 25 | } 26 | 27 | public AllProxiesJsonServlet(Registry registry) { 28 | super(registry); 29 | } 30 | 31 | @Override 32 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 33 | doPost(req, resp); 34 | } 35 | 36 | @Override 37 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 38 | process(req, resp); 39 | 40 | } 41 | 42 | protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException { 43 | response.setContentType("text/json"); 44 | response.setCharacterEncoding("UTF-8"); 45 | response.setStatus(200); 46 | JSONObject res; 47 | try { 48 | res = getResponse(); 49 | response.getWriter().print(res.toString(4)); 50 | response.getWriter().close(); 51 | } catch (JSONException e) { 52 | throw new GridException(e.getMessage()); 53 | } 54 | 55 | } 56 | 57 | private JSONObject getResponse() throws IOException, JSONException { 58 | JSONObject requestJSON = new JSONObject(); 59 | ProxySet proxies = this.getRegistry().getAllProxies(); 60 | Iterator iterator = proxies.iterator(); 61 | JSONArray p = new JSONArray(); 62 | while (iterator.hasNext()) { 63 | RemoteProxy eachProxy = iterator.next(); 64 | p.put(eachProxy.getOriginalRegistrationRequest().getAssociatedJSON()); 65 | } 66 | requestJSON.put("Proxies", p); 67 | 68 | return requestJSON; 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /src/main/java/com/seleniumgrid2api/servlet/ProxyStatusJsonServlet.java: -------------------------------------------------------------------------------- 1 | package com.seleniumgrid2api.servlet; 2 | 3 | import org.json.JSONArray; 4 | import org.json.JSONException; 5 | import org.json.JSONObject; 6 | import org.openqa.grid.common.exception.GridException; 7 | import org.openqa.grid.internal.ProxySet; 8 | import org.openqa.grid.internal.Registry; 9 | import org.openqa.grid.internal.RemoteProxy; 10 | import org.openqa.grid.web.servlet.RegistryBasedServlet; 11 | 12 | import javax.servlet.ServletException; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import java.io.IOException; 16 | import java.util.Iterator; 17 | 18 | public class ProxyStatusJsonServlet extends RegistryBasedServlet { 19 | 20 | private static final long serialVersionUID = -1975392591408983229L; 21 | 22 | public ProxyStatusJsonServlet() { 23 | this(null); 24 | } 25 | 26 | public ProxyStatusJsonServlet(Registry registry) { 27 | super(registry); 28 | } 29 | 30 | @Override 31 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 32 | doPost(req, resp); 33 | } 34 | 35 | @Override 36 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 37 | process(req, resp); 38 | 39 | } 40 | 41 | protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException { 42 | response.setContentType("text/json"); 43 | response.setCharacterEncoding("UTF-8"); 44 | response.setStatus(200); 45 | JSONObject res; 46 | try { 47 | res = getResponse(); 48 | response.getWriter().print(res.toString(4)); 49 | response.getWriter().close(); 50 | } catch (JSONException e) { 51 | throw new GridException(e.getMessage()); 52 | } 53 | 54 | } 55 | 56 | private JSONObject getResponse() throws IOException, JSONException { 57 | JSONObject requestJSON = new JSONObject(); 58 | ProxySet proxies = this.getRegistry().getAllProxies(); 59 | Iterator iterator = proxies.iterator(); 60 | JSONArray busyProxies = new JSONArray(); 61 | JSONArray freeProxies = new JSONArray(); 62 | while (iterator.hasNext()) { 63 | RemoteProxy eachProxy = iterator.next(); 64 | if (eachProxy.isBusy()) { 65 | busyProxies.put(eachProxy.getOriginalRegistrationRequest().getAssociatedJSON()); 66 | } else { 67 | freeProxies.put(eachProxy.getOriginalRegistrationRequest().getAssociatedJSON()); 68 | } 69 | } 70 | requestJSON.put("BusyProxies", busyProxies); 71 | requestJSON.put("FreeProxies", freeProxies); 72 | 73 | return requestJSON; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | selenium-grid2-api 2 | ================== 3 | 4 | This is an attempt to document the Grid2 API endpoints, along with some code to interact with same and give some sample 5 | custom proxies, html renderers and capability matchers. Oh, and some servlets too. 6 | 7 | 8 | 9 | Grid2 available endpoints: 10 | * /grid/console/ 11 | * /grid/beta/console/ 12 | * /grid/register/ 13 | * /grid/driver/ 14 | * /wd/hub/ 15 | * /selenium-server/driver/ 16 | * /grid/resources/ 17 | * /grid/api/proxy/ 18 | * /grid/api/hub/ 19 | * /grid/api/testsession/ 20 | * /lifecycle-manager/ 21 | 22 | console 23 | ------- 24 | * /grid/console/ 25 | * /grid/beta/console/ 26 | 27 | This is the default view of the grid, showing the connected nodes and their test slots both free and busy. 28 | 29 | **base url:** 30 | ``` 31 | http://localhost:4444/grid/console/ 32 | http://localhost:4444/grid/beta/console/ 33 | ``` 34 | 35 | /grid/register/ 36 | --------------- 37 | Used to register a node on the hub. 38 | 39 | **base url:** 40 | ``` 41 | http://localhost:4444/grid/register/ 42 | ``` 43 | 44 | **parameter formats accepted:** 45 | ``` 46 | JSON as per https://code.google.com/p/selenium/wiki/DesiredCapabilities 47 | ``` 48 | 49 | **sample request:** 50 | ``` 51 | http://localhost:4444/grid/register/ 52 | ``` 53 | 54 | **response:** 55 | ``` 56 | "ok" 57 | ``` 58 | 59 | /grid/driver/ 60 | ------------- 61 | 62 | **base url:** 63 | ``` 64 | http://localhost:4444/grid/driver/ 65 | ``` 66 | 67 | **parameter formats accepted:** 68 | ``` 69 | ``` 70 | 71 | **sample request:** 72 | ``` 73 | http://localhost:4444/grid/driver/ 74 | ``` 75 | 76 | **response:** 77 | ``` 78 | ``` 79 | 80 | /wd/hub 81 | ------- 82 | 83 | **base url:** 84 | ``` 85 | http://localhost:4444/wd/hub 86 | ``` 87 | 88 | **parameter formats accepted:** 89 | ``` 90 | url parameters 91 | ``` 92 | 93 | **sample request:** 94 | ``` 95 | http://localhost:4444/wd/hub/status 96 | ``` 97 | 98 | **response from hub:** 99 | ``` 100 | { 101 | "status": 13, 102 | "value": { 103 | "message": "Session [(null externalkey)] not available and is not among the last 1000 terminated sessions.\nActive sessions are[ext. key bf655635-3ef8-4997-865f-3a00ffadf01e, ext. key b3a098fa-4dce-47ca-8ed0-8bc02e734155, 5cf0bdd3-07e9-4dd7-a1e1-9c87da8b8c4c (int. key, remote not contacted yet.), ext. key 5ae2b631-d8fe-40dc-8851-a9415290b6dd, ext. key f575c810-aa50-43ad-973c-dfed62660a34, ext. key d466b0ba-4cbc-4aa1-a785-92ffa486e86b]", 104 | "class": "org.openqa.grid.common.exception.GridException", 105 | "stackTrace": [ 106 | { 107 | "fileName": "ActiveTestSessions.java", 108 | "lineNumber": 109, 109 | "className": "org.openqa.grid.internal.ActiveTestSessions", 110 | "methodName": "getExistingSession" 111 | }, 112 | { 113 | "fileName": "Registry.java", 114 | "lineNumber": 423, 115 | "className": "org.openqa.grid.internal.Registry", 116 | "methodName": "getExistingSession" 117 | }, 118 | { 119 | "fileName": "RequestHandler.java", 120 | "lineNumber": 234, 121 | "className": "org.openqa.grid.web.servlet.handler.RequestHandler", 122 | "methodName": "getSession" 123 | } 124 | ] 125 | } 126 | } 127 | ``` 128 | 129 | **response from node:** 130 | ``` 131 | { 132 | "sessionId": null, 133 | "status": 0, 134 | "value": { 135 | "os": { 136 | "arch": "x86", 137 | "name": "Windows XP", 138 | "version": "5.1" 139 | }, 140 | "java": { 141 | "version": "1.7.0_21" 142 | }, 143 | "build": { 144 | "revision": "unknown", 145 | "time": "unknown", 146 | "version": "unknown" 147 | } 148 | }, 149 | "state": "success", 150 | "class": "org.openqa.selenium.remote.Response", 151 | "hCode": 4684600 152 | } 153 | ``` 154 | 155 | /grid/resources/ 156 | ---------------- 157 | 158 | Allows you to access resources stored in the server .jar file. 159 | 160 | **base url:** 161 | ``` 162 | http://localhost:4444/grid/resources/ 163 | ``` 164 | 165 | **parameter formats accepted:** 166 | ``` 167 | url parameters 168 | ``` 169 | 170 | **sample request:** 171 | ``` 172 | http://localhost:4444/grid/resources/org/openqa/grid/images/console-beta.js 173 | ``` 174 | 175 | **response:** 176 | ``` 177 | The contents of the console-beta.js 178 | ``` 179 | 180 | /grid/api/proxy/ 181 | ---------------- 182 | 183 | **base url:** 184 | ``` 185 | http://localhost:4444/grid/api/proxy/ 186 | ``` 187 | 188 | **parameter formats accepted:** 189 | ``` 190 | JSON, url parameters 191 | ``` 192 | 193 | **sample request:** 194 | ``` 195 | http://localhost:4444/grid/api/proxy/ 196 | 197 | { 198 | "id": "http://10.105.140.42:5555" 199 | } 200 | 201 | or 202 | 203 | { 204 | "id":"http://10.105.140.42:5555", 205 | "isAlive":"" 206 | } 207 | 208 | or 209 | 210 | http://localhost:4444/grid/api/proxy?id=http://10.20.30.40:5555 211 | ``` 212 | 213 | **sample response:** 214 | ``` 215 | { 216 | "id": "http://10.105.140.42:5555", 217 | "request": { 218 | "class": "org.openqa.grid.common.RegistrationRequest", 219 | "capabilities": [ 220 | { 221 | "platform": "XP", 222 | "browserName": "internet explorer", 223 | "maxInstances": "1", 224 | "version": "7" 225 | }, 226 | { 227 | "platform": "XP", 228 | "browserName": "firefox", 229 | "maxInstances": "2", 230 | "version": "9" 231 | }, 232 | { 233 | "platform": "XP", 234 | "browserName": "chrome", 235 | "maxInstances": "2" 236 | } 237 | ], 238 | "configuration": { 239 | "port": 5555, 240 | "hubConfig": "hubServlets.json", 241 | "registerCycle": 5000, 242 | "hub": "http://10.20.30.40:4444/grid/register", 243 | "newSessionWaitTimeout": -1, 244 | "remoteHost": "http://10.105.140.42:5555", 245 | "prioritizer": null, 246 | "throwOnCapabilityNotPresent": true, 247 | "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", 248 | "browser": "browserName=internet explorer,platform=XP,version=7,maxInstances=1", 249 | "maxSession": 5, 250 | "role": "node", 251 | "Dport=5556": "ensureCleanSession=true", 252 | "Dwebdriver.ie.driver=C:\\automation\\IEDriverServer.exe": "", 253 | "servlets": "com.groupon.SeleniumGridExtrasServlet", 254 | "host": "10.105.140.42", 255 | "cleanUpCycle": 5000, 256 | "browserTimeout": 600000, 257 | "hubHost": "autotestweb-002", 258 | "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher", 259 | "url": "http://10.105.140.42:5555", 260 | "register": true, 261 | "nodePolling": 5000, 262 | "Dwebdriver.server.session.timeout": "120", 263 | "hubPort": 4444, 264 | "Dwebdriver.chrome.driver=C:\\automation\\chromedriver.exe": "", 265 | "timeout": 600000 266 | } 267 | }, 268 | "msg": "proxy found !", 269 | "success": true 270 | } 271 | ``` 272 | 273 | /grid/api/hub/ 274 | -------------- 275 | API to query the hub config remotely. 276 | 277 | use the API by sending a GET to grid/api/hub/ 278 | with the content of the request in JSON,specifying the 279 | parameters you're interesting in, for instance, to get 280 | the timeout of the hub and the registered servlets : 281 | 282 | **base url:** 283 | ``` 284 | http://localhost:4444/grid/api/hub/ 285 | ``` 286 | 287 | **parameter formats accepted:** 288 | ``` 289 | JSON 290 | ``` 291 | 292 | **sample request:** 293 | ``` 294 | http://localhost:4444/grid/api/hub/ 295 | 296 | {"configuration": 297 | [ 298 | "timeout", 299 | "servlets" 300 | ] 301 | } 302 | 303 | if no param is specified, all params known to the hub are returned. 304 | 305 | {"configuration": [] } 306 | 307 | ``` 308 | 309 | **sample response:** 310 | ``` 311 | { 312 | "port": 4444, 313 | "servlets": "", 314 | "host": null, 315 | "throwOnCapabilityNotPresent": true, 316 | "cleanUpCycle": 5000, 317 | "nodePolling": 5000, 318 | "browserTimeout": 0, 319 | "maxSession": 5, 320 | "role": "hub", 321 | "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher", 322 | "newSessionWaitTimeout": -1, 323 | "success": true, 324 | "timeout": 300000, 325 | "prioritizer": null 326 | } 327 | ``` 328 | 329 | /grid/api/testsession/ 330 | ---------------------- 331 | 332 | 333 | **base url:** 334 | ``` 335 | http://localhost:4444/grid/api/testsession/ 336 | ``` 337 | 338 | **parameter formats accepted:** 339 | ``` 340 | url parameters, JSON 341 | ``` 342 | 343 | **sample request:** 344 | ``` 345 | http://localhost:4444/grid/api/testsession?session=196555 346 | ``` 347 | 348 | **sample response:** 349 | ``` 350 | 351 | ``` 352 | 353 | /lifecycle-manager 354 | ----------------- 355 | 356 | The only implemented action is to shutdown the hub. 357 | 358 | **base url:** 359 | ``` 360 | http://localhost:4444/lifecycle-manager 361 | ``` 362 | 363 | **parameter formats accepted:** 364 | ``` 365 | url parameters 366 | ``` 367 | 368 | **sample request:** 369 | ``` 370 | http://localhost:4444/lifecycle-manager?action=shutdown 371 | ``` 372 | 373 | **sample response:** 374 | ``` 375 | null 376 | ``` 377 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2012-2013 ios-driver committers 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------