Sean Condon | 3c8e558 | 2018-08-28 23:22:43 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 3 | * |
| 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 | */ |
| 16 | package org.onosproject.ui.impl.gui2; |
| 17 | |
| 18 | import org.onlab.rest.BaseResource; |
| 19 | |
| 20 | import javax.servlet.http.HttpServletRequest; |
| 21 | import javax.ws.rs.GET; |
| 22 | import javax.ws.rs.Path; |
| 23 | import javax.ws.rs.core.Context; |
| 24 | import javax.ws.rs.core.Response; |
| 25 | import java.io.IOException; |
| 26 | import java.net.URI; |
| 27 | import java.net.URISyntaxException; |
| 28 | |
| 29 | /** |
| 30 | * Application upload resource for GUI 2. |
| 31 | */ |
| 32 | @Path("logout") |
| 33 | public 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(); |
Sean Condon | bf7ff4f | 2019-03-17 16:18:42 +0000 | [diff] [blame] | 42 | url = url.replaceFirst("/onos/ui/.*", "/onos/ui/login.html"); |
Sean Condon | 3c8e558 | 2018-08-28 23:22:43 +0100 | [diff] [blame] | 43 | return Response.temporaryRedirect(new URI(url)).build(); |
| 44 | } |
| 45 | |
| 46 | } |