Elasticsearch MockSocket

Allows using sockets without having to grant dangerous permissions to all of your code.

License

License

Categories

Categories

Search Business Logic Libraries Elasticsearch
GroupId

GroupId

org.elasticsearch
ArtifactId

ArtifactId

mocksocket
Last Version

Last Version

1.2
Release Date

Release Date

Type

Type

jar
Description

Description

Elasticsearch MockSocket
Allows using sockets without having to grant dangerous permissions to all of your code.
Project URL

Project URL

https://github.com/elastic/mocksocket
Source Code Management

Source Code Management

https://github.com/elastic/mocksocket

Download mocksocket

How to add to project

<!-- https://jarcasting.com/artifacts/org.elasticsearch/mocksocket/ -->
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>mocksocket</artifactId>
    <version>1.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.elasticsearch/mocksocket/
implementation 'org.elasticsearch:mocksocket:1.2'
// https://jarcasting.com/artifacts/org.elasticsearch/mocksocket/
implementation ("org.elasticsearch:mocksocket:1.2")
'org.elasticsearch:mocksocket:jar:1.2'
<dependency org="org.elasticsearch" name="mocksocket" rev="1.2">
  <artifact name="mocksocket" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.elasticsearch', module='mocksocket', version='1.2')
)
libraryDependencies += "org.elasticsearch" % "mocksocket" % "1.2"
[org.elasticsearch/mocksocket "1.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

mocksocket

Allows using sockets without having to grant dangerous permissions to all of your code.

This wraps the Socket and ServerSocket apis with AccessController blocks. No code changes are needed.

Instead of:

grant {
  // give scary permission to all code just for tests
  permission java.net.SocketPermission "*", "accept,connect,resolve";
};

You can do:

<dependency>
  <groupId>org.elasticsearch</groupId>
  <artifactId>mocksocket</artifactId>
  <version>1.0</version>
  <scope>test</scope>
</dependency>
...
grant codeBase "/url/to/mocksocket-1.0.jar" {
  // only allow this jar used in tests to do this
  permission java.net.SocketPermission "*", "accept,connect,resolve";
};
org.elasticsearch

elastic

Versions

Version
1.2
1.1
1.0