Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/OldServer/src/org/litesoft/GWT/eventbus/server/AuthenticatedServerEventBus.java

Diff revisions: vs.
  @@ -8,19 +8,16 @@
8 8 import org.litesoft.*;
9 9 import org.litesoft.commonfoundation.typeutils.*;
10 10
11 - public class AuthenticatedServerEventBus extends NonTemporaryServerEventBus
12 - {
11 + public class AuthenticatedServerEventBus extends NonTemporaryServerEventBus {
13 12 private AuthenticatedServerEventBusSupport mSupport;
14 13 private IAuthenticationService mAuthenticationService;
15 14
16 - public Type getType()
17 - {
15 + public Type getType() {
18 16 return Type.Authenticated;
19 17 }
20 18
21 19 public AuthenticatedServerEventBus( int pClientIdNumber, AuthenticatedServerEventBusSupport pSupport,
22 - IAuthenticationService pAuthenticationService )
23 - {
20 + IAuthenticationService pAuthenticationService ) {
24 21 super( pClientIdNumber );
25 22
26 23 Objects.assertNotNull( "AuthenticatedServerEventBusSupport", mSupport = pSupport );
  @@ -29,16 +26,13 @@
29 26 IAuthenticationService.Null.INSTANCE;
30 27 }
31 28
32 - public ISystemUser getLoggedInUser()
33 - {
29 + public ISystemUser getLoggedInUser() {
34 30 return mSupport.getLoggedInUserFromSEB( this );
35 31 }
36 32
37 - public AuthenticationData getAuthenticationData()
38 - {
33 + public AuthenticationData getAuthenticationData() {
39 34 ISystemUser user = getLoggedInUser();
40 - if ( user == null )
41 - {
35 + if ( user == null ) {
42 36 String zLogoutMessage = mSupport.getLogoutMessageFromSEB( this );
43 37 return new AuthenticationData( zLogoutMessage );
44 38 }
  @@ -49,8 +43,7 @@
49 43 }
50 44
51 45 protected AuthenticationData createSuccessfulAuthenticationData( ISystemUser pUser,
52 - AppXtraLoginData pAppXtraLoginData )
53 - {
46 + AppXtraLoginData pAppXtraLoginData ) {
54 47 String zLoginUser = pUser.getLoginName();
55 48 String zUserKeyAsOpaqueString = pUser.getKeyAsOpaqueString();
56 49 String zUserDisplayName = pUser.getDisplayName();
  @@ -60,20 +53,15 @@
60 53 pAppXtraLoginData );
61 54 }
62 55
63 - public String isLocalDistributionFromPeerOK( EventPackage pPackage )
64 - {
65 - try
66 - {
67 - if ( pPackage instanceof AuthenticationEventPackage )
68 - {
69 - if ( pPackage instanceof SignOutEventPackage )
70 - {
56 + public String isLocalDistributionFromPeerOK( EventPackage pPackage ) {
57 + try {
58 + if ( pPackage instanceof AuthenticationEventPackage ) {
59 + if ( pPackage instanceof SignOutEventPackage ) {
71 60 SignOutEventPackage zSignOutRequest = (SignOutEventPackage) pPackage;
72 61 signOut( zSignOutRequest.getMessage() );
73 62 return null;
74 63 }
75 - if ( pPackage instanceof SignInRequestEventPackage )
76 - {
64 + if ( pPackage instanceof SignInRequestEventPackage ) {
77 65 SignInRequestEventPackage zSignInRequest = (SignInRequestEventPackage) pPackage;
78 66 signIn( zSignInRequest.getLoginName(), zSignInRequest.getPassword() );
79 67 return null;
  @@ -83,48 +71,40 @@
83 71
84 72 return (mSupport.getLoggedInUserFromSEB( this ) != null) ? null : "Not Authenticated";
85 73 }
86 - catch ( RuntimeException e )
87 - {
74 + catch ( RuntimeException e ) {
88 75 // Fail on every kind of exception
89 76 return "Exception: " + e.getMessage();
90 77 }
91 78 }
92 79
93 - private void signOut( String pLogoutMessage )
94 - {
80 + private void signOut( String pLogoutMessage ) {
95 81 mSupport.clearLoggedInUserInformationOnSEB( this );
96 82 mSupport.setLogoutMessageOnSEB( this, pLogoutMessage );
97 83 mSupport.logoutRequestComplete( this );
98 84 }
99 85
100 - private void signIn( String pLoginName, String pPassword )
101 - {
86 + private void signIn( String pLoginName, String pPassword ) {
102 87 mSupport.clearLogoutMessageOnSEB( this );
103 88
104 89 ISystemUser zSystemUser;
105 - try
106 - {
90 + try {
107 91 zSystemUser = mSupport.authenticate( pLoginName, pPassword );
108 - if ( zSystemUser == null )
109 - {
92 + if ( zSystemUser == null ) {
110 93 signInError( "Invalid User" );
111 94 return;
112 95 }
113 96 mAuthenticationService.adjustExistingClientWindowInstanceDataForNewUser(
114 97 getClientWindowInstanceDataManager(), zSystemUser );
115 98 }
116 - catch ( AuthenticationException e )
117 - {
99 + catch ( AuthenticationException e ) {
118 100 signInError( e.getMessage() );
119 101 return;
120 102 }
121 - catch ( IllegalArgumentException e )
122 - {
103 + catch ( IllegalArgumentException e ) {
123 104 signInError( e.getMessage() );
124 105 return;
125 106 }
126 - catch ( RuntimeException e )
127 - {
107 + catch ( RuntimeException e ) {
128 108 mLogger.error.log( e );
129 109 signInError( "Authentication Issue" );
130 110 return;
  @@ -137,13 +117,11 @@
137 117 SignInResponseEventPackage.send( this, zAuthenticationData );
138 118 }
139 119
140 - private void signInError( String pError )
141 - {
120 + private void signInError( String pError ) {
142 121 SignInResponseEventPackage.send( this, new AuthenticationData( pError ) );
143 122 }
144 123
145 - public String toString()
146 - {
124 + public String toString() {
147 125 return "Authenticated" + super.toString();
148 126 }
149 127 }