Giter VIP home page Giter VIP logo

rscp-e3dc's Introduction

rscp-e3dc License: MIT

A library to assist in constructing RSCP (remote storage control protocol) frames and data to communicate with E3DC servers.

RSCP is a proprietary protocol from E3/DC GmbH.

This library is available under the MIT license.

Requirements

  • JDK 1.8+
  • Maven 3.6

How to use it

Add dependency

Add a dependency in your pom.xml:

    <dependencies>
        <dependency>
            <groupId>io.github.bvotteler</groupId>
            <artifactId>e3dc-rscp</artifactId>
            <version>1.0.1</version>
        </dependency>
    </dependencies>

Constructing a frame

To construct a frame, we can use RSCPData.Builder in combination with RSCPFrame.Builder.

Typically, we want to start with an authentication frame like this:

// set user name (same as used to login to the portal)
RSCPData authUser = RSCPData.builder()
        .tag(RSCPTag.TAG_RSCP_AUTHENTICATION_USER)
        .stringValue(user)
        .build();

// add password (same as used to login to the portal)
RSCPData authPwd = RSCPData.builder()
        .tag(RSCPTag.TAG_RSCP_AUTHENTICATION_PASSWORD)
        .stringValue(password)
        .build();

// combine user/password into a authentication request container
RSCPData authContainer = RSCPData.builder()
        .tag(RSCPTag.TAG_RSCP_REQ_AUTHENTICATION)
        .containerValues(Arrays.asList(authUser, authPwd))
        .build();

// put the authentication request into a frame
RSCPFrame authFrame = RSCPFrame.builder()
        .addData(authContainer)
        .timestamp(Instant.now())
        .build();

// get byte array ready to be encrypted and sent to the server
byte[] frame = authFrame.getAsByteArray();

Reading a received frame

Similarly, we can use the received, decrypted byte array to inspect the response.

// assuming we have the response byte array in byte[] response...
RSCPFrame frame = RSCPFrame.builder()
        .buildFromRawBytes(response);

// get the contents of the frame
List<RSCPData> dataList = frame.getData();
// an authentication response contains a single data set with the authentication level
// as CHAR8 value which fits into a Java short
RSCPData authData = dataList.get(0);
// read optional short (will be empty if the data cannot be expressed as short)
Optional<Short> authLevel = authData.getValueAsInt();

Sample project

rscp-e3dc-sample is a sample project showing how this library could be used.

It shows how to construct an authentication frame, as well as a database request frame. In addition, it shows how to encrypt and decrypt frames sent to/received from E3DC servers.

Build

Build the library with:

mvn clean compile

Test

Run the tests with:

mvn test

Package

To package the project, run:

mvn package

You can also configure your local repository for Maven, then run:

mvn package install

rscp-e3dc's People

Contributors

bvotteler avatar bjoernbrings avatar

Watchers

James Cloos avatar Daniel Luckas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.