Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.downloader / org.gvsig.downloader.swing / org.gvsig.downloader.swing.scribejava / src / main / java / org / gvsig / downloader / swing / scribejava / keycloak / callbacks / CallbackLogoutHandler.java @ 47828

History | View | Annotate | Download (1.82 KB)

1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.downloader.swing.scribejava.keycloak.callbacks;
7

    
8
import com.github.scribejava.core.oauth.OAuth20Service;
9
import com.sun.net.httpserver.HttpExchange;
10
import com.sun.net.httpserver.HttpHandler;
11
import java.io.IOException;
12
import org.gvsig.downloader.swing.scribejava.keycloak.DownloaderAuthenticationKeycloakRequester;
13

    
14
/**
15
 *
16
 * @author jjdelcerro
17
 */
18
@SuppressWarnings("UseSpecificCatch")
19
public class CallbackLogoutHandler extends AbstractCallback implements HttpHandler {
20
    
21
    public CallbackLogoutHandler(DownloaderAuthenticationKeycloakRequester identificationRequester, OAuth20Service service, String contextPath) {
22
        super(identificationRequester, service, contextPath);
23
    }
24

    
25
    @Override
26
    public void handle(HttpExchange t) throws IOException {
27
        String requestURL = "Unknown";
28
        try {
29
            requestURL = t.getRequestURI().toString();
30
//            LOGGER.info("Callback logout "+requestURL);
31
            response(t, 200, 
32
                    message_and_close(
33
                            "\n\n\n\n\n\n\n\n\n\n<p align=\"center\">Session closed</p>\n\n<p align=\"center\"><button type=\"button\" onclick=\"self.close()\">Close this window</button></p>\n\n"
34
                    )                    
35
            ); // +t.getRequestURI().toString()+"\n"));
36
        } catch (Exception ex) {
37
            LOGGER.warn("Can't process callback authorization (contextPath '" + contextPath + "', request URL '" + requestURL + "')", ex);
38
            responseQuietly(t, 500, message("Can't authenticate user<br>\n" + ex.getMessage()));
39
        } finally {
40
            this.stopWaitingForResponse();
41
        }
42
    }
43
    
44
    
45
}