public abstract class CifsAuthenticator extends java.lang.Object implements ICifsAuthenticator
An authenticator is used by the CIFS server to authenticate users when in user level access mode and authenticate requests to connect to a share when in share level access.
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
GUEST_USERNAME |
protected ServerConfigurationAccessor |
m_config |
protected java.util.Random |
m_random |
AUTH_ACCDISABLED, AUTH_ALLOW, AUTH_BADPASSWORD, AUTH_BADUSER, AUTH_DISALLOW, AUTH_GUEST, AUTH_PASSEXPIRED, LANMAN, NoAccess, NTLM1, NTLM2, ReadOnly, SHARE_MODE, STANDARD_CHALLENGE_LEN, STANDARD_PASSWORD_LEN, USER_MODE, Writeable
Constructor and Description |
---|
CifsAuthenticator() |
Modifier and Type | Method and Description |
---|---|
boolean |
allowGuest() |
int |
authenticateShareConnect(ClientInfo client,
SharedDevice share,
java.lang.String sharePwd,
SrvSession sess)
Authenticate a connection to a share.
|
int |
authenticateUser(ClientInfo client,
SrvSession sess,
int alg)
Authenticate a user.
|
int |
authenticateUserPlainText(ClientInfo client,
SrvSession sess) |
void |
closeAuthenticator()
Close the authenticator, perform any cleanup
|
protected byte[] |
convertPassword(java.lang.String pwd)
Convert the password string to a byte array
|
protected void |
doGuestLogon(ClientInfo client,
SrvSession sess)
Logon using the guest user account
|
protected byte[] |
generateEncryptedPassword(java.lang.String plainPwd,
byte[] encryptKey,
int alg,
java.lang.String userName,
java.lang.String domain)
Encrypt the plain text password with the specified encryption key using the specified
encryption algorithm.
|
void |
generateNegotiateResponse(SMBSrvSession sess,
SMBSrvPacket respPkt,
boolean extendedSecurity)
Generate the CIFS negotiate response packet, the authenticator should add authentication
specific fields to the response.
|
int |
getAccessMode()
Return the access mode of the server, either SHARE_MODE or USER_MODE.
|
AuthContext |
getAuthContext(SMBSrvSession sess) |
CIFSConfigSection |
getCIFSConfig() |
DialectSelector |
getEnabledDialects() |
int |
getEncryptionKeyLength()
Return the encryption key/challenge length
|
protected PasswordEncryptor |
getEncryptor()
Return the password encryptor
|
java.lang.String |
getGuestUserName() |
SecurityConfigSection |
getsecurityConfig()
Return the security configuration section
|
int |
getSecurityMode()
Return the security mode flags
|
int |
getServerCapabilities()
Return the server capability flags
|
protected java.lang.String |
getStatusAsString(int sts)
Return the authentication status as a string
|
UserAccount |
getUserDetails(java.lang.String user) |
boolean |
hasDebug() |
boolean |
hasExtendedSecurity()
Determine if extended security methods are available
|
boolean |
hasSessionCleanup()
Cleanup existing sessions from the same client address/name
|
void |
initialize()
Initialize the authenticator, after properties have been set
|
void |
initialize(ServerConfiguration config,
org.springframework.extensions.config.ConfigElement params)
Initialize the authenticator
|
protected java.lang.String |
mapClientAddressToDomain(java.net.InetAddress clientIP)
Map a client IP address to a domain
|
boolean |
mapUnknownUserToGuest() |
void |
processSessionSetup(SMBSrvSession sess,
SMBSrvPacket reqPkt)
Process the CIFS session setup request packet and build the session setup response
|
void |
setAccessMode(int mode)
Set the access mode of the server.
|
void |
setAllowGuest(boolean ena)
Enable/disable the guest account
|
void |
setConfig(ServerConfigurationAccessor config) |
void |
setCurrentUser(ClientInfo client)
Set the current authenticated user context for this thread
|
void |
setDebug(boolean debug) |
protected void |
setExtendedSecurity(boolean extSec)
Set the extended security flag
|
void |
setGuestUserName(java.lang.String guest)
Set the guest user name
|
void |
setMapToGuest(boolean ena)
Enable/disable mapping of unknown users to the guest account
|
protected void |
setSecurityMode(int flg)
Set the security mode flags
|
void |
setSessionCleanup(boolean ena)
Enable/disable session cleanup when a new logon is received using virtual circuit zero
|
java.lang.String |
toString()
Generate a description for debugging purposes
|
protected boolean |
validatePassword(UserAccount user,
ClientInfo client,
AuthContext authCtx,
int alg)
Validate a password by encrypting the plain text password using the specified encryption key
and encryption algorithm.
|
protected static final java.lang.String GUEST_USERNAME
protected java.util.Random m_random
protected ServerConfigurationAccessor m_config
public void setDebug(boolean debug)
debug
- activate debug mode?public void setConfig(ServerConfigurationAccessor config)
config
- an accessor for the file server configuration sectionspublic int authenticateShareConnect(ClientInfo client, SharedDevice share, java.lang.String sharePwd, SrvSession sess)
ICifsAuthenticator
authenticateShareConnect
in interface ICifsAuthenticator
client
- User/client details from the tree connect request.share
- Shared device the client wants to connect to.sharePwd
- Share password.sess
- Server session.public int authenticateUser(ClientInfo client, SrvSession sess, int alg)
ICifsAuthenticator
authenticateUser
in interface ICifsAuthenticator
client
- User/client details from the session setup request.sess
- Server sessionalg
- Encryption algorithmpublic final int authenticateUserPlainText(ClientInfo client, SrvSession sess)
public void initialize() throws InvalidConfigurationException
InvalidConfigurationException
public void initialize(ServerConfiguration config, org.springframework.extensions.config.ConfigElement params) throws InvalidConfigurationException
config
- ServerConfigurationparams
- ConfigElementInvalidConfigurationException
protected final byte[] generateEncryptedPassword(java.lang.String plainPwd, byte[] encryptKey, int alg, java.lang.String userName, java.lang.String domain)
plainPwd
- StringencryptKey
- byte[]alg
- intuserName
- Stringdomain
- Stringpublic final int getAccessMode()
ICifsAuthenticator
getAccessMode
in interface ICifsAuthenticator
public final boolean hasExtendedSecurity()
ICifsAuthenticator
hasExtendedSecurity
in interface ICifsAuthenticator
public AuthContext getAuthContext(SMBSrvSession sess)
public final DialectSelector getEnabledDialects()
public final int getSecurityMode()
ICifsAuthenticator
getSecurityMode
in interface ICifsAuthenticator
public final CIFSConfigSection getCIFSConfig()
public final SecurityConfigSection getsecurityConfig()
public final boolean hasDebug()
public void generateNegotiateResponse(SMBSrvSession sess, SMBSrvPacket respPkt, boolean extendedSecurity) throws AuthenticatorException
ICifsAuthenticator
generateNegotiateResponse
in interface ICifsAuthenticator
sess
- SMBSrvSessionrespPkt
- SMBSrvPacketextendedSecurity
- booleanAuthenticatorException
public void processSessionSetup(SMBSrvSession sess, SMBSrvPacket reqPkt) throws SMBSrvException
ICifsAuthenticator
processSessionSetup
in interface ICifsAuthenticator
sess
- SMBSrvSessionreqPkt
- SMBSrvPacketSMBSrvException
public int getEncryptionKeyLength()
ICifsAuthenticator
getEncryptionKeyLength
in interface ICifsAuthenticator
public int getServerCapabilities()
ICifsAuthenticator
getServerCapabilities
in interface ICifsAuthenticator
public final boolean allowGuest()
public final java.lang.String getGuestUserName()
public final boolean mapUnknownUserToGuest()
public final void setAllowGuest(boolean ena)
ena
- Enable the guest account if true, only allow defined user accounts access if falsepublic final void setGuestUserName(java.lang.String guest)
guest
- Stringpublic final void setMapToGuest(boolean ena)
ena
- Enable mapping of unknown users to the guest if trueprotected final void setSecurityMode(int flg)
flg
- intprotected final void setExtendedSecurity(boolean extSec)
extSec
- booleanpublic final boolean hasSessionCleanup()
public void setSessionCleanup(boolean ena)
ena
- booleanpublic void closeAuthenticator()
ICifsAuthenticator
closeAuthenticator
in interface ICifsAuthenticator
protected final boolean validatePassword(UserAccount user, ClientInfo client, AuthContext authCtx, int alg)
user
- UserAccountclient
- ClientInfoauthCtx
- AuthContextalg
- intprotected final byte[] convertPassword(java.lang.String pwd)
pwd
- Stringprotected final PasswordEncryptor getEncryptor()
protected final java.lang.String getStatusAsString(int sts)
sts
- intpublic final void setAccessMode(int mode)
mode
- Either SHARE_MODE or USER_MODE.protected void doGuestLogon(ClientInfo client, SrvSession sess)
client
- ClientInfosess
- SrvSessionpublic final UserAccount getUserDetails(java.lang.String user)
public void setCurrentUser(ClientInfo client)
setCurrentUser
in interface ICifsAuthenticator
client
- ClientInfoprotected final java.lang.String mapClientAddressToDomain(java.net.InetAddress clientIP)
clientIP
- InetAddresspublic java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.