blob: 27e31584eeb215d2aba68257e62957c6495eb1e1 [file] [log] [blame]
Thomas Vachuskaeff0e4e2015-08-11 00:26:24 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuskaeff0e4e2015-08-11 00:26:24 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.ui.impl;
17
18import org.onlab.rest.BaseResource;
19
20import javax.servlet.http.HttpServletRequest;
21import javax.ws.rs.GET;
22import javax.ws.rs.Path;
23import javax.ws.rs.core.Context;
24import javax.ws.rs.core.Response;
25import java.io.IOException;
26import java.net.URI;
27import java.net.URISyntaxException;
28
29/**
30 * Application upload resource.
31 */
32@Path("logout")
33public class LogoutResource extends BaseResource {
34
35 @Context
36 private HttpServletRequest servletRequest;
37
38 @GET
39 public Response logout() throws IOException, URISyntaxException {
40 servletRequest.getSession().invalidate();
41 String url = servletRequest.getRequestURL().toString();
42 url = url.replaceFirst("/onos/ui/.*", "/onos/ui/login.html");
43 return Response.temporaryRedirect(new URI(url)).build();
44 }
45
46}