|
@@ -1,60 +1,60 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.eventbus.server; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.eventbus.server.nonpublic.*; |
5 |
|
- |
import org.litesoft.*; |
6 |
|
- |
import org.litesoft.commonfoundation.typeutils.*; |
7 |
|
- |
|
8 |
|
- |
public abstract class AbstractAuthenticatingServerApp extends AbstractServerApp |
9 |
|
- |
implements AuthenticatedServerEventBusSupport { |
10 |
|
- |
public static final String LOGOUT_MESSAGE_KEY = "LogoutMessage"; |
11 |
|
- |
|
12 |
|
- |
public String getLogoutMessageFromSEB( ServerEventBus pServerEventBus ) { |
13 |
|
- |
return (String) pServerEventBus.getClientWindowInstanceData( LOGOUT_MESSAGE_KEY ); |
14 |
|
- |
} |
15 |
|
- |
|
16 |
|
- |
public void setLogoutMessageOnSEB( ServerEventBus pServerEventBus, String pLogoutMessage ) { |
17 |
|
- |
pServerEventBus.setClientWindowInstanceData( LOGOUT_MESSAGE_KEY, pLogoutMessage ); |
18 |
|
- |
ServerEventBusSessionMapper.setLogoutMessage( getThreadLocalRequest(), this, pLogoutMessage ); |
19 |
|
- |
} |
20 |
|
- |
|
21 |
|
- |
public void clearLogoutMessageOnSEB( ServerEventBus pServerEventBus ) { |
22 |
|
- |
pServerEventBus.removeClientWindowInstanceData( LOGOUT_MESSAGE_KEY ); |
23 |
|
- |
} |
24 |
|
- |
|
25 |
|
- |
private IAuthenticationService mAuthenticationService = null; |
26 |
|
- |
|
27 |
|
- |
protected AbstractAuthenticatingServerApp( IAuthenticationService pAuthenticationService ) { |
28 |
|
- |
mAuthenticationService = pAuthenticationService; |
29 |
|
- |
} |
30 |
|
- |
|
31 |
|
- |
protected NonTemporaryServerEventBus createRealServerEventBus( int pClientIdNumber ) { |
32 |
|
- |
return mAuthenticationService == null ? // |
33 |
|
- |
super.createRealServerEventBus( pClientIdNumber ) : // |
34 |
|
- |
createAuthenticatedServerEventBus( pClientIdNumber, mAuthenticationService ); |
35 |
|
- |
} |
36 |
|
- |
|
37 |
|
- |
protected AuthenticatedServerEventBus createAuthenticatedServerEventBus( int pClientIdNumber, |
38 |
|
- |
IAuthenticationService pAuthenticationService ) { |
39 |
|
- |
return new AuthenticatedServerEventBus( pClientIdNumber, this, pAuthenticationService ); |
40 |
|
- |
} |
41 |
|
- |
|
42 |
|
- |
protected IAuthenticationService getAuthenticationService() { |
43 |
|
- |
return (mAuthenticationService != null) ? // |
44 |
|
- |
mAuthenticationService : // |
45 |
|
- |
IAuthenticationService.Null.INSTANCE; |
46 |
|
- |
} |
47 |
|
- |
|
48 |
|
- |
/** |
49 |
|
- |
* Authenticate (find a SystemUser) based on the pLoginName, pPlainTextPassword. |
50 |
|
- |
* |
51 |
|
- |
* @return found SystemUser |
52 |
|
- |
* |
53 |
|
- |
* @throws AuthenticationException if No SystemUser or SystemUser not allowed to Login, Exception message is the text to the user |
54 |
|
- |
*/ |
55 |
|
- |
public ISystemUser authenticate( String pLoginName, String pPlainTextPassword ) |
56 |
|
- |
throws AuthenticationException { |
57 |
|
- |
return getAuthenticationService().authenticate( Strings.deNull( pLoginName ).trim(), // |
58 |
|
- |
Strings.deNull( pPlainTextPassword ).trim() ); |
59 |
|
- |
} |
60 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.eventbus.server; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.eventbus.server.nonpublic.*; |
|
5 |
+ |
import org.litesoft.*; |
|
6 |
+ |
import org.litesoft.commonfoundation.base.*; |
|
7 |
+ |
|
|
8 |
+ |
public abstract class AbstractAuthenticatingServerApp extends AbstractServerApp |
|
9 |
+ |
implements AuthenticatedServerEventBusSupport { |
|
10 |
+ |
public static final String LOGOUT_MESSAGE_KEY = "LogoutMessage"; |
|
11 |
+ |
|
|
12 |
+ |
public String getLogoutMessageFromSEB( ServerEventBus pServerEventBus ) { |
|
13 |
+ |
return (String) pServerEventBus.getClientWindowInstanceData( LOGOUT_MESSAGE_KEY ); |
|
14 |
+ |
} |
|
15 |
+ |
|
|
16 |
+ |
public void setLogoutMessageOnSEB( ServerEventBus pServerEventBus, String pLogoutMessage ) { |
|
17 |
+ |
pServerEventBus.setClientWindowInstanceData( LOGOUT_MESSAGE_KEY, pLogoutMessage ); |
|
18 |
+ |
ServerEventBusSessionMapper.setLogoutMessage( getThreadLocalRequest(), this, pLogoutMessage ); |
|
19 |
+ |
} |
|
20 |
+ |
|
|
21 |
+ |
public void clearLogoutMessageOnSEB( ServerEventBus pServerEventBus ) { |
|
22 |
+ |
pServerEventBus.removeClientWindowInstanceData( LOGOUT_MESSAGE_KEY ); |
|
23 |
+ |
} |
|
24 |
+ |
|
|
25 |
+ |
private IAuthenticationService mAuthenticationService = null; |
|
26 |
+ |
|
|
27 |
+ |
protected AbstractAuthenticatingServerApp( IAuthenticationService pAuthenticationService ) { |
|
28 |
+ |
mAuthenticationService = pAuthenticationService; |
|
29 |
+ |
} |
|
30 |
+ |
|
|
31 |
+ |
protected NonTemporaryServerEventBus createRealServerEventBus( int pClientIdNumber ) { |
|
32 |
+ |
return mAuthenticationService == null ? // |
|
33 |
+ |
super.createRealServerEventBus( pClientIdNumber ) : // |
|
34 |
+ |
createAuthenticatedServerEventBus( pClientIdNumber, mAuthenticationService ); |
|
35 |
+ |
} |
|
36 |
+ |
|
|
37 |
+ |
protected AuthenticatedServerEventBus createAuthenticatedServerEventBus( int pClientIdNumber, |
|
38 |
+ |
IAuthenticationService pAuthenticationService ) { |
|
39 |
+ |
return new AuthenticatedServerEventBus( pClientIdNumber, this, pAuthenticationService ); |
|
40 |
+ |
} |
|
41 |
+ |
|
|
42 |
+ |
protected IAuthenticationService getAuthenticationService() { |
|
43 |
+ |
return (mAuthenticationService != null) ? // |
|
44 |
+ |
mAuthenticationService : // |
|
45 |
+ |
IAuthenticationService.Null.INSTANCE; |
|
46 |
+ |
} |
|
47 |
+ |
|
|
48 |
+ |
/** |
|
49 |
+ |
* Authenticate (find a SystemUser) based on the pLoginName, pPlainTextPassword. |
|
50 |
+ |
* |
|
51 |
+ |
* @return found SystemUser |
|
52 |
+ |
* |
|
53 |
+ |
* @throws AuthenticationException if No SystemUser or SystemUser not allowed to Login, Exception message is the text to the user |
|
54 |
+ |
*/ |
|
55 |
+ |
public ISystemUser authenticate( String pLoginName, String pPlainTextPassword ) |
|
56 |
+ |
throws AuthenticationException { |
|
57 |
+ |
return getAuthenticationService().authenticate( ConstrainTo.notNull( pLoginName ).trim(), // |
|
58 |
+ |
ConstrainTo.notNull( pPlainTextPassword ).trim() ); |
|
59 |
+ |
} |
|
60 |
+ |
} |