public class SimpleAuthenticationServiceImpl extends Object implements AuthenticationService
KShieldClient
Modifier and Type | Field and Description |
---|---|
protected KShieldClient |
client |
protected HttpClientConnectionManager |
connManager |
protected CloseableHttpClient |
httpClient |
protected String |
url |
Constructor and Description |
---|
SimpleAuthenticationServiceImpl(String url) |
Modifier and Type | Method and Description |
---|---|
void |
checkService()
Checks KeyShield SSO Server status
|
protected void |
checkUrl() |
protected SSLConnectionSocketFactory |
createSSLSocketFactory() |
UserInfo |
createUserInfo(String ipAddr)
Retrieves userInfo from KeyShield SSO Server, Returns null if ip address is not validated by server, ip address cannot by validated or ip address is empty
Non-null return value means that ipAddr was approved by KeyShield SSO Server
|
void |
destroy()
Cleanup Authentication service before destruction (In Spring v 3.x and Guice IOC called automatically)
|
EnumSet<UserInfo.AuthType> |
getAllowedAuthTypes() |
String |
getApiKey() |
int |
getConnectionTimeout()
Returns http connection timeout in milliseconds - default is 5000
|
protected String[] |
getMergedAttributes() |
ResponseLevel |
getResponseLevel() |
int |
getSoTimeout()
Return SO_TIMEOUT in milliseconds - default is 5000
|
String |
getTrustStorePath() |
String |
getUrl() |
UserInfoValidator |
getUserInfoValidator()
Return custom userInfo validator
|
String |
getUsernameAttribute() |
protected boolean |
hasOptionalAttributes() |
protected boolean |
hasTrustStore() |
protected boolean |
hasUsernameAttr() |
void |
init()
Initializes Authentication service after creation (In Spring v 3.x and Guice IOC called automatically)
|
protected KeyStore |
loadTrustStore() |
void |
sendClientMessage(ClientMessage msg)
Sends message to another user(s) idetified by IP or FDN
|
void |
sendClientMessage(String from,
String to,
String message)
Sends message to another user(s) idetified by IP or FDN
|
void |
setAllowedAuthTypes(EnumSet<UserInfo.AuthType> allowAuthTypes)
Sets allowed authentication types
|
void |
setApiKey(String apiKey)
Sets KeyShield SSO API authorization key
|
void |
setConnectionTimeout(int connectionTimeout)
Sets http connection timeout in milliseconds - default is 5000
|
void |
setOptionalAttributes(String... attrs)
Set optional attributes requested from KeyShield SSO with UserInfo
|
void |
setResponseLevel(ResponseLevel responseLevel)
Sets optional response level used in KeyShieldSSO requests
It is possible to set this dynamically after init() method
|
void |
setSoTimeout(int soTimeout)
Set SO_TIMEOUT in milliseconds - default is 5000
|
void |
setTrustStorePath(String trustStorePath)
Sets custom JKS truststore path
This truststore will be used as in memory keystore - all certificates are treated as trusted
|
void |
setUrl(String url)
Sets KeyShield SSO Server url
|
void |
setUserInfoValidator(UserInfoValidator userInfoValidator)
Set custom userInfo validator
|
void |
setUsernameAttribute(String usernameAttr)
Set name of attribute used as username instead of screenName
This attribute is automatically merged with optional attributes
|
protected KShieldClient client
protected HttpClientConnectionManager connManager
protected CloseableHttpClient httpClient
public SimpleAuthenticationServiceImpl(String url)
url
- KeyShield SSO Server urlpublic void checkService() throws KShieldClientException
AuthenticationService
checkService
in interface AuthenticationService
KShieldClientException
- in case of other communication or validation errorprotected void checkUrl()
protected SSLConnectionSocketFactory createSSLSocketFactory()
public UserInfo createUserInfo(String ipAddr)
AuthenticationService
createUserInfo
in interface AuthenticationService
ipAddr
- remote request IP addressUserInfo
if successfully authenticated or null otherwise@PreDestroy public void destroy()
destroy
in interface AuthenticationService
public EnumSet<UserInfo.AuthType> getAllowedAuthTypes()
UserInfo.AuthType
public int getConnectionTimeout()
protected String[] getMergedAttributes()
public ResponseLevel getResponseLevel()
ResponseLevel
public int getSoTimeout()
public String getTrustStorePath()
public UserInfoValidator getUserInfoValidator()
public String getUsernameAttribute()
protected boolean hasOptionalAttributes()
protected boolean hasTrustStore()
protected boolean hasUsernameAttr()
@PostConstruct public void init()
Important - call this method after creation and overall setup of AuthenticationService instance
init
in interface AuthenticationService
protected KeyStore loadTrustStore()
public void sendClientMessage(ClientMessage msg) throws KShieldClientException
AuthenticationService
sendClientMessage
in interface AuthenticationService
msg
- Client message dataKShieldClientException
- in case of other communication or validation errorpublic void sendClientMessage(String from, String to, String message) throws KShieldClientException
AuthenticationService
sendClientMessage
in interface AuthenticationService
from
- Name (Full Name) of message senderto
- Message target (IP or FDN)message
- Message textKShieldClientException
- in case of other communication or validation errorpublic void setAllowedAuthTypes(EnumSet<UserInfo.AuthType> allowAuthTypes)
Important - set this before init() method call
allowAuthTypes
- set of allowed authentication typesUserInfo.AuthType
public void setApiKey(String apiKey)
Important - set this before init() method call
apiKey
- public void setConnectionTimeout(int connectionTimeout)
Important - set this before init() method call
connectionTimeout
- public void setOptionalAttributes(String... attrs)
Important - set this before init() method call
attrs
- optional attributes namespublic void setResponseLevel(ResponseLevel responseLevel)
responseLevel
- public void setSoTimeout(int soTimeout)
Important - set this before init() method call
soTimeout
- public void setTrustStorePath(String trustStorePath)
Important - set this before init() method call
trustStorePath
- public void setUrl(String url)
Important - set this before init() method call
public void setUserInfoValidator(UserInfoValidator userInfoValidator)
public void setUsernameAttribute(String usernameAttr)
Important - set this before init() method call
usernameAttr
- name of username attributeCopyright © 2013 TDP Ltd. All Rights Reserved.