4
4
***********************************************************************************
5
5
*
6
6
* Copyright (c) 2008 The Sakai Foundation.
7
- *
7
+ *
8
8
* Licensed under the Educational Community License, Version 1.0 (the "License");
9
9
* you may not use this file except in compliance with the License.
10
10
* You may obtain a copy of the License at
11
- *
11
+ *
12
12
* http://www.opensource.org/licenses/ecl1.php
13
- *
13
+ *
14
14
* Unless required by applicable law or agreed to in writing, software
15
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -89,7 +89,7 @@ public class SkinnableLogin extends HttpServlet implements Login {
89
89
private transient LoginService loginService ;
90
90
91
91
private static ResourceLoader rb = new ResourceLoader ("auth" );
92
-
92
+
93
93
// the list of login choices that could be supplied
94
94
enum AuthChoices {
95
95
CONTAINER ,
@@ -137,7 +137,7 @@ public String getServletInfo()
137
137
138
138
@ SuppressWarnings (value = "HRS_REQUEST_PARAMETER_TO_HTTP_HEADER" , justification = "Looks like the data is already URL encoded" )
139
139
protected void doGet (HttpServletRequest req , HttpServletResponse res )
140
- throws ServletException , IOException
140
+ throws ServletException , IOException
141
141
{
142
142
// get the session
143
143
Session session = SessionManager .getCurrentSession ();
@@ -174,7 +174,7 @@ else if ("/xlogin".equals(option))
174
174
{
175
175
176
176
// if this is an impersonation, then reset the users old session and
177
- if (isImpersonating ())
177
+ if (isImpersonating ())
178
178
{
179
179
UsageSession oldSession = (UsageSession ) session .getAttribute (UsageSessionService .USAGE_SESSION_KEY );
180
180
String impersonatingEid = session .getUserEid ();
@@ -191,12 +191,12 @@ else if ("/xlogin".equals(option))
191
191
session .setUserEid (userEid );
192
192
authzGroupService .refreshUser (userId );
193
193
194
- try
194
+ try
195
195
{
196
196
res .sendRedirect (serverConfigurationService .getString ("portalPath" , "/portal" ));
197
197
res .getWriter ().close ();
198
- }
199
- catch (IOException e )
198
+ }
199
+ catch (IOException e )
200
200
{
201
201
log .error ("failed to redirect after impersonating" , e );
202
202
}
@@ -221,7 +221,11 @@ else if ("/xlogin".equals(option))
221
221
}
222
222
return ;
223
223
}
224
-
224
+ if (session != null && session .getUserId () != null ) {
225
+ String returnUrl = (String ) session .getAttribute (Tool .HELPER_DONE_URL );
226
+ complete (returnUrl , session , tool , res );
227
+ }
228
+
225
229
//SAK-29092 if an auth is specified in the URL, skip any other checks and go straight to it
226
230
String authPreferred = req .getParameter ("auth" );
227
231
log .debug ("authPreferred: " + authPreferred );
@@ -230,7 +234,7 @@ else if ("/xlogin".equals(option))
230
234
log .debug ("Going straight to xlogin" );
231
235
skipContainer = true ;
232
236
}
233
-
237
+
234
238
// see if we need to check container
235
239
boolean checkContainer = serverConfigurationService .getBoolean ("container.login" , false );
236
240
if (checkContainer && !skipContainer )
@@ -267,8 +271,8 @@ else if ("/xlogin".equals(option))
267
271
log .debug ("Going straight to container login" );
268
272
showAuthChoice = false ;
269
273
}
270
-
271
- if (showAuthChoice && !(StringUtils .isEmpty (helperPath ) || helperPath .equals ("/portal" ) ||
274
+
275
+ if (showAuthChoice && !(StringUtils .isEmpty (helperPath ) || helperPath .equals ("/portal" ) ||
272
276
helperPath .equals ("/portal/" ) )) {
273
277
String xloginUrl = serverConfigurationService .getPortalUrl () + "/xlogin" ;
274
278
@@ -395,7 +399,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse res) throws Se
395
399
// Decide whether or not to put up the Cancel
396
400
String portalUrl = (String ) session .getAttribute (Tool .HELPER_DONE_URL );
397
401
String actualPortal = serverConfigurationService .getPortalUrl ();
398
- if ( portalUrl != null && portalUrl .indexOf ("/site/" ) < 1 && portalUrl .startsWith (actualPortal ) ) {
402
+ if ( portalUrl != null && portalUrl .indexOf ("/site/" ) < 1 && portalUrl .startsWith (actualPortal ) ) {
399
403
rcontext .put ("doCancel" , Boolean .TRUE );
400
404
}
401
405
@@ -603,7 +607,7 @@ protected String getPasswordResetUrl()
603
607
/**
604
608
* Helper to log failed login attempts (SAK-22430)
605
609
* @param credentials the credentials supplied
606
- *
610
+ *
607
611
* Note that this could easily be extedned to track login attempts per session and report on it here
608
612
*/
609
613
private void logFailedAttempt (LoginCredentials credentials ) {
@@ -615,30 +619,30 @@ private void logFailedAttempt(LoginCredentials credentials) {
615
619
616
620
/**
617
621
* Helper to see if this session has used SuTool to become another user
618
- *
622
+ *
619
623
* Returns true if the user is currently impersonating.
620
624
*/
621
- private boolean isImpersonating ()
625
+ private boolean isImpersonating ()
622
626
{
623
627
Session s = SessionManager .getCurrentSession ();
624
628
String userId = s .getUserId ();
625
629
UsageSession session = (UsageSession ) s .getAttribute (UsageSessionService .USAGE_SESSION_KEY );
626
630
627
- if (session != null )
631
+ if (session != null )
628
632
{
629
633
// If we have a session for this user, simply reuse
630
634
if (userId != null )
631
635
{
632
636
if (userId .equals (session .getUserId ()))
633
637
{
634
638
return false ;
635
- }
636
- else
639
+ }
640
+ else
637
641
{
638
642
return true ;
639
643
}
640
644
}
641
- else
645
+ else
642
646
{
643
647
log .error ("null userId in check isImpersonating" );
644
648
}
0 commit comments