git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-access/ckan-connector@129478 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b989f80dd5
commit
e189ae57b8
7
pom.xml
7
pom.xml
|
@ -1,6 +1,13 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.gcube.data.access</groupId>
|
||||
<artifactId>ckan-connector</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.io.FileInputStream;
|
|||
import java.net.URI;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
|
@ -45,19 +45,31 @@ public class ConnectorManager {
|
|||
|
||||
|
||||
@Path("disconnect")
|
||||
@DELETE
|
||||
public Response disconnect() {
|
||||
@GET
|
||||
public Response disconnect(@Context HttpServletRequest req) {
|
||||
log.info("disconnect called ");
|
||||
String hostname = context.getInitParameter("hostname");
|
||||
try{
|
||||
return Response.ok()
|
||||
.header(
|
||||
"Set-Cookie",
|
||||
String.format("auth_tkt=deleted;Domain=.%s;Path=/;Expires=Thu, 01-Jan-1970 00:00:01 GMT",hostname)
|
||||
).build();
|
||||
boolean found = false;
|
||||
for (Cookie cookie : req.getCookies())
|
||||
if (cookie.getName().equals("auth_tkt")){
|
||||
found=true;
|
||||
break;
|
||||
}
|
||||
if (found)
|
||||
return Response.ok(context.getClassLoader().getResourceAsStream("logout.html"))
|
||||
.header(
|
||||
"Set-Cookie",
|
||||
String.format("auth_tkt=deleted;Domain=%s;Path=/;Expires=Thu, 01-Jan-1970 00:00:01 GMT",hostname)
|
||||
)
|
||||
.header("Set-Cookie",
|
||||
String.format("ckan_hide_header=deleted;Domain=%s;Path=/;Expires=Thu, 01-Jan-1970 00:00:01 GMT",hostname)
|
||||
).build();
|
||||
else return Response.ok(context.getClassLoader().getResourceAsStream("inactivesession.html")).build();
|
||||
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
log.error("error disconnecting ",e);
|
||||
return Response.serverError().build();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<body>
|
||||
<h2 style="text-align:center;">CKAN session is invalid<h2>
|
||||
</body>
|
|
@ -0,0 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
<h1 style="text-align:center;">Successfully logged out from CKAN</h1>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue