-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSampleAuthenticator.java
46 lines (39 loc) · 1.33 KB
/
SampleAuthenticator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Created Mar 29, 2006
*/
package example;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.hannonhill.cascade.model.security.authentication.AuthenticationPhase;
import com.hannonhill.cascade.model.security.authentication.Authenticator;
/**
* Sample authenticator that mimicks a SSO webapp.
*
* @author Collin VanDyck
* @since 4.0
*/
public class SampleAuthenticator implements Authenticator
{
public boolean redirect(HttpServletRequest request, HttpServletResponse response, AuthenticationPhase phase) throws IOException
{
if (phase == AuthenticationPhase.LOGIN)
{
// mimick that the user has already authenticated, and redirect back to the custom authentication
// servlet
response.sendRedirect("http://localhost:8080" + AUTHENTICATION_URI);
return true;
}
else if (phase == AuthenticationPhase.LOGOUT)
{
// we don't have a external auth webapp, so we'll just redirect here to the web site.
response.sendRedirect("http://www.hannonhill.com");
return true;
}
return false;
}
public String authenticate(HttpServletRequest request, HttpServletResponse response)
{
return "admin2";
}
}