@GridSpiInfo(author="GridGain Systems", url="www.gridgain.com", email="support@gridgain.com", version="6.0.2.${gg.ver.build}") @GridSpiMultipleInstancesSupport(value=true) public class GridRememberMeSecureSessionSpi extends GridSpiAdapter implements GridSecureSessionSpi, GridRememberMeSecureSessionSpiMBean
It generates a secure session token with encapsulated session data and data signature, encrypted with secret key. On request this SPI validates received token with secret key and re-generate new token.
setTtl(long))setSecretKey(String))setSigner(GridRememberMeConverter))setEncoder(GridRememberMeConverter))setDecoder(GridRememberMeConverter))
GridRememberMeSecureSessionSpi spi = new GridRememberMeSecureSessionSpi();
// Set session expiration time for 1 hour.
spi.setTtl(60 * 60 * 1000);
// Set data signature secret key.
spi.setSecretKey("1001 hedgehogs");
GridConfiguration cfg = new GridConfiguration();
// Override default SecureSession SPI.
cfg.setSecureSessionSpi(spi);
// Start grid.
GridGain.start(cfg);
<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfiguration" singleton="true">
...
<property name="secureSessionSpi">
<bean class="org.gridgain.grid.spi.SecureSession.rememberme.GridRememberMeSecureSessionSpi">
<property name="ttl" value="3600000"/>
<property name="secretKey" value="1001 hedgehogs"/>
</bean>
</property>
...
</bean>
For information about Spring framework visit www.springframework.org
GridSecureSessionSpi| Constructor and Description |
|---|
GridRememberMeSecureSessionSpi() |
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
createToken(byte[] subjId)
Create token for specified subject ID.
|
String |
getDecoderFormatted()
Gets decoder string representation.
|
String |
getEncoderFormatted()
Gets encoder string representation.
|
String |
getSecretKey()
Gets session signature secret key used for signing and validation.
|
String |
getSignerFormatted()
Gets signer string representation.
|
long |
getTtl()
Get session token expiration time (in milliseconds)
|
protected boolean |
isValidToken(byte[] subjId,
byte[] tok)
Validate session token against subject ID.
|
void |
setDecoder(GridRememberMeConverter decoder)
Set new session token decoder.
|
void |
setEncoder(GridRememberMeConverter encoder)
Set new session token encoder.
|
void |
setSecretKey(String secretKey)
Sets session signature secret key used for signing and validation.
|
void |
setSigner(GridRememberMeConverter signer)
Set new data signer to sign/verify session data integrity.
|
void |
setTtl(long ttl)
Sets session expiration time (in milliseconds).
|
protected byte[] |
sign(byte[] subjId,
long createTime)
Sign data.
|
void |
spiStart(String gridName)
This method is called to start SPI.
|
void |
spiStop()
This method is called to stop SPI.
|
boolean |
supported(GridSecuritySubjectType subjType)
Checks if given subject is supported by this SPI.
|
String |
toString() |
byte[] |
validate(GridSecuritySubjectType subjType,
byte[] subjId,
byte[] tok,
Object params)
Validates a given token and returns a valid
"remember-me" session token. |
assertParameter, checkConfigurationConsistency0, configInfo, createSpiAttributeName, getAuthor, getConsistentAttributeNames, getGridGainHome, getLocalNodeId, getName, getNodeAttributes, getSpiContext, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion, injectables, onContextDestroyed, onContextDestroyed0, onContextInitialized, onContextInitialized0, registerMBean, setJson, setName, startInfo, startStopwatch, stopInfo, unregisterMBeanclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetName, getNodeAttributes, onContextDestroyed, onContextInitializedsetJsongetAuthor, getGridGainHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion@GridSpiConfiguration(optional=true) public void setEncoder(GridRememberMeConverter encoder)
encoder - New session token encoder.public String getEncoderFormatted()
getEncoderFormatted in interface GridRememberMeSecureSessionSpiMBean@GridSpiConfiguration(optional=true) public void setDecoder(GridRememberMeConverter decoder)
decoder - New session token decoder.public String getDecoderFormatted()
getDecoderFormatted in interface GridRememberMeSecureSessionSpiMBean@GridSpiConfiguration(optional=true) public void setSigner(GridRememberMeConverter signer)
signer - New data signer to sign/verify session data integrity.public String getSignerFormatted()
getSignerFormatted in interface GridRememberMeSecureSessionSpiMBeanpublic String getSecretKey()
getSecretKey in interface GridRememberMeSecureSessionSpiMBean@GridSpiConfiguration(optional=true) public void setSecretKey(String secretKey)
setSecretKey in interface GridRememberMeSecureSessionSpiMBeansecretKey - new session token signature secret key.public long getTtl()
getTtl in interface GridRememberMeSecureSessionSpiMBean@GridSpiConfiguration(optional=true) public void setTtl(long ttl)
setTtl in interface GridRememberMeSecureSessionSpiMBeanttl - New session token expiration time (in milliseconds)public boolean supported(GridSecuritySubjectType subjType)
supported in interface GridSecureSessionSpisubjType - Subject type.True if subject type is supported, false otherwise.public byte[] validate(GridSecuritySubjectType subjType, byte[] subjId, @Nullable byte[] tok, @Nullable Object params) throws GridSpiException
"remember-me" session token.
If passed in token is null, then this is a first time token generation
and a new session token will be created.
Otherwise, the passed in token is validated and if validation passes, then
the next value for session token is returned. If failed, then null is returned.
validate in interface GridSecureSessionSpisubjType - Subject type.subjId - Unique subject ID such as local or remote node ID, client ID, etc.tok - If null, then this is the first request and new session
token should be created, otherwise, the token will be validated and next session
token will be generated.params - Additional implementation-specific parameters.null if validation failed.GridSpiException - If validation resulted in system error. Note that
bad credentials should not cause this exception.protected byte[] createToken(byte[] subjId)
throws GridSpiException
subjId - Unique subject ID such as local or remote node ID, client ID, etc.GridSpiException - If token creation resulted in system error.protected boolean isValidToken(byte[] subjId,
byte[] tok)
throws GridSpiException
subjId - Unique subject ID such as local or remote node ID, client ID, etc.tok - Session token to validate.true if session token is valid, false - otherwise.GridSpiException - If session validation resulted in system error.protected byte[] sign(byte[] subjId,
long createTime)
throws GridSpiException
subjId - Unique subject ID such as local or remote node ID, client ID, etc.createTime - Token creation time.GridSpiException - If data signing resulted in system error.public void spiStart(String gridName) throws GridSpiException
spiStart in interface GridSpigridName - Name of grid instance this SPI is being started for
(null for default grid).GridSpiException - Throws in case of any error during SPI start.public void spiStop()
throws GridSpiException
Note that this method can be called at any point including during recovery of failed start. It should make no assumptions on what state SPI will be in when this method is called.
spiStop in interface GridSpiGridSpiException - Thrown in case of any error during SPI stop.
Core Products
:
Data Grid ver. 6.0.2,
Streaming ver. 6.0.2
Accelerators
:
Hadoop Accelerator ver. 6.0.2
Release Date
:
March 24 2014