org.apache.ignite.internal.processors.rest.protocols

## Class GridRestProtocolAdapter

- java.lang.Object
- - org.apache.ignite.internal.processors.rest.protocols.GridRestProtocolAdapter

All Implemented Interfaces:
  GridRestProtocol

Direct Known Subclasses:
  GridTcpRestProtocol

    public abstract class GridRestProtocolAdapter
    extends Object
    implements GridRestProtocol

Abstract protocol adapter.

### Field Summary

Fields
`protected GridKernalContext` `ctx` Context.
`protected InetAddress` `host` Host used by this protocol.
`protected IgniteLogger` `log` Logger.
`protected int` `port` Port used by this protocol.
`protected String` `secretKey` Secret key.

### Constructor Summary

Constructors
`protected` `GridRestProtocolAdapter(GridKernalContext ctx)`

### Method Summary

Methods
`protected void` `assertParameter(boolean cond, String condDesc)`
`protected boolean` `authenticate(String tok)` Authenticates current request.
`protected ConnectorConfiguration` `config()`
`protected abstract String` `getAddressPropertyName()` Return node attribute name to store used address.
`protected abstract String` `getHostNamePropertyName()` Return node attribute name to store used host name.
`protected abstract String` `getPortPropertyName()` Return node attribute name to store used port number.
`Collection<IgniteBiTuple<String,Object>>` `getProperties()` Returns protocol properties for setting node attributes.
`void` `onKernalStart()` Grid start callback.
`protected String` `startInfo()`
`protected String` `stopInfo()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.ignite.internal.processors.rest.GridRestProtocol

`name, start, stop`

### Field Detail

#### ctx

    protected final GridKernalContext ctx

Context.

#### log

    protected final IgniteLogger log

Logger.

#### secretKey

    protected final String secretKey

Secret key.

#### host

    protected InetAddress host

Host used by this protocol.

#### port

    protected int port

Port used by this protocol.

### Constructor Detail

#### GridRestProtocolAdapter

    protected GridRestProtocolAdapter(GridKernalContext ctx)

Parameters:
  `ctx` - Context.

### Method Detail

#### authenticate

    protected boolean authenticate(@Nullable
                       String tok)

Authenticates current request.

Token consists of 2 parts separated by semicolon:

1. Timestamp (time in milliseconds)
2. Base64 encoded SHA1 hash of {1}:{secretKey}

Parameters:
  `tok` - Authentication token.
Returns:
  `true` if authentication info provided in request is correct.

#### startInfo

    protected String startInfo()

Returns:
  Start information string.

#### stopInfo

    protected String stopInfo()

Returns:
  Stop information string.

#### assertParameter

    protected final void assertParameter(boolean cond,
                       String condDesc)
                                  throws IgniteCheckedException

Parameters:
  `cond` - Condition to check.
  `condDesc` - Error message.
Throws:
  `IgniteCheckedException` - If check failed.

#### config

    protected ConnectorConfiguration config()

Returns:
  Client configuration.

#### getProperties

    public Collection<IgniteBiTuple<String,Object>> getProperties()

Returns protocol properties for setting node attributes. Has meaningful result only after protocol start.

Specified by:
  `getProperties` in interface `GridRestProtocol`
Returns:
  Protocol properties.

#### getAddressPropertyName

    protected abstract String getAddressPropertyName()

Return node attribute name to store used address.

Returns:
  Node attribute name.

#### getHostNamePropertyName

    protected abstract String getHostNamePropertyName()

Return node attribute name to store used host name.

Returns:
  Node attribute name.

#### getPortPropertyName

    protected abstract String getPortPropertyName()

Return node attribute name to store used port number.

Returns:
  Node attribute name.

#### onKernalStart

    public void onKernalStart()

Grid start callback.

Specified by:
  `onKernalStart` in interface `GridRestProtocol`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.7.0
Release Date | : August 1 2016