GridGain™ 4.3.1e
Enterprise "Big Data" Edition

org.gridgain.grid.spi.authentication.jaas
Class GridJaasAuthenticationSpi

java.lang.Object
  extended by org.gridgain.grid.spi.GridSpiAdapter
      extended by org.gridgain.grid.spi.authentication.jaas.GridJaasAuthenticationSpi
All Implemented Interfaces:
GridAuthenticationSpi, GridJaasAuthenticationSpiMBean, GridSpi, GridSpiJsonConfigurable, GridSpiManagementMBean

@GridSpiInfo(author="GridGain Systems",
             url="www.gridgain.com",
             email="support@gridgain.com",
             version="4.3.1e.10112012")
@GridSpiMultipleInstancesSupport(value=true)
public class GridJaasAuthenticationSpi
extends GridSpiAdapter
implements GridAuthenticationSpi, GridJaasAuthenticationSpiMBean

JAAS-based implementation of the authentication SPI.

On authentication request this SPI delegates authentication to the externally configured JAAS login module in accordance with JAAS Reference Guide:

  1. SPI creates new callback handler via configured GridJaasCallbackHandlerFactory, which provides subject credentials in format acceptable by the JAAS login module.
  2. SPI passes context name and callback handler into the JAAS login context.
  3. JAAS login context delegates authentication to the JAAS login module specified by the context name.
  4. JAAS login module requests subject credentials from the callback handler and perform authentication.

Configuration

Mandatory

The following configuration parameters are required:

Optional

The following configuration parameters are optional:

Java Example

 GridJaasAuthenticationSpi authSpi = getSpi();

 // Override JAAS login context name.
 authSpi.setLoginContextName("GridJaasLoginContext");

 // Override callback handler's factory.
 authSpi.setCallbackHandlerFactory(new GridJaasCallbackHandlerFactorySample());

 GridConfigurationAdapter cfg = new GridConfigurationAdapter();

 // Override default authentication SPI.
 cfg.setAuthenticationSpi(authSpi);

 // Start grid.
 GridFactory.start(cfg);
 

Spring Example

GridPasscodeAuthenticationSpi can be configured from Spring XML configuration file:
 <bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
         ...
         <property name="authenticationSpi">
             <bean class="org.gridgain.grid.spi.authentication.jaas.GridJaasAuthenticationSpi">
                 <property name="loginContextName" value="GridJaasLoginContext"/>
                 <property name="callbackHandlerFactory">
                     <bean class="org.gridgain.grid.spi.authentication.jaas.GridJaasCallbackHandlerFactorySample"/>
                 </property>
             </bean>
         </property>
         ...
 </bean>
 


For information about Spring framework visit www.springframework.org

 

Constructor Summary
GridJaasAuthenticationSpi()
           
 
Method Summary
 boolean authenticate(GridSecuritySubjectType subjType, byte[] subjId, Object creds)
          Authenticates a given subject (either node or remote client).
 String getCallbackHandlerFactoryFormatted()
          Gets JAAS-authentication callback handler factory name.
 String getLoginContextName()
          Gets login context name.
 void setCallbackHandlerFactory(GridJaasCallbackHandlerFactory callbackHndFactory)
          Sets JAAS-implementation specific callback handler factory.
 void setLoginContextName(String loginCtxName)
          Sets new login context name.
 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()
          
 
Methods inherited from class org.gridgain.grid.spi.GridSpiAdapter
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, unregisterMBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.gridgain.grid.spi.GridSpi
getName, getNodeAttributes, onContextDestroyed, onContextInitialized
 
Methods inherited from interface org.gridgain.grid.spi.GridSpiJsonConfigurable
setJson
 
Methods inherited from interface org.gridgain.grid.spi.GridSpiManagementMBean
getAuthor, getGridGainHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion
 

Constructor Detail

GridJaasAuthenticationSpi

public GridJaasAuthenticationSpi()
Method Detail

getLoginContextName

public String getLoginContextName()
Gets login context name.

Specified by:
getLoginContextName in interface GridJaasAuthenticationSpiMBean
Returns:
Login context name.

setLoginContextName

@GridSpiConfiguration(optional=true)
public void setLoginContextName(String loginCtxName)
Sets new login context name.

Specified by:
setLoginContextName in interface GridJaasAuthenticationSpiMBean
Parameters:
loginCtxName - New login context name.

getCallbackHandlerFactoryFormatted

public String getCallbackHandlerFactoryFormatted()
Gets JAAS-authentication callback handler factory name.

Specified by:
getCallbackHandlerFactoryFormatted in interface GridJaasAuthenticationSpiMBean
Returns:
JAAS-authentication callback handler factory name.

setCallbackHandlerFactory

@GridSpiConfiguration(optional=false)
public void setCallbackHandlerFactory(GridJaasCallbackHandlerFactory callbackHndFactory)
Sets JAAS-implementation specific callback handler factory.

Parameters:
callbackHndFactory - JAAS-implementation specific callback handler factory.

authenticate

public boolean authenticate(GridSecuritySubjectType subjType,
                            byte[] subjId,
                            @Nullable
                            Object creds)
                     throws GridSpiException
Authenticates a given subject (either node or remote client).

Specified by:
authenticate in interface GridAuthenticationSpi
Throws:
GridSpiException - If authentication resulted in system error. Note that bad credentials should not cause this exception.
Parameters:
subjType - Subject type.
subjId - Unique subject ID such as local or remote node ID, client ID, etc.
creds - Authentication parameters (may be null or empty based on implementation). The map of parameters may be different for different subject types. Refer to specific authentication SPI documentation for a list of required parameters.
Returns:
true if authentication passed, false if authentication failed.

supported

public boolean supported(GridSecuritySubjectType subjType)
Checks if given subject is supported by this SPI. If not, then next authentication SPI in the list will be checked.

Specified by:
supported in interface GridAuthenticationSpi
Parameters:
subjType - Subject type.
Returns:
True if subject type is supported, false otherwise.

spiStart

public void spiStart(String gridName)
              throws GridSpiException
This method is called to start SPI. After this method returns successfully kernel assumes that SPI is fully operational.

Specified by:
spiStart in interface GridSpi
Throws:
GridSpiException - Throws in case of any error during SPI start.
Parameters:
gridName - Name of grid instance this SPI is being started for (null for default grid).

spiStop

public void spiStop()
             throws GridSpiException
This method is called to stop SPI. After this method returns kernel assumes that this SPI is finished and all resources acquired by it are released.

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.

Specified by:
spiStop in interface GridSpi
Throws:
GridSpiException - Thrown in case of any error during SPI stop.

toString

public String toString()

Overrides:
toString in class Object

GridGain™ 4.3.1e
Enterprise "Big Data" Edition

GridGain - In-Memory Big Data
Enterprise "Big Data" Edition, ver. 4.3.1e.10112012
2012 Copyright © GridGain Systems
Follow us:   Follow GridGain on Github Join GridGain User Group Follow GridGain on Twitter Follow GridGain on Vimeo