Thomas Vachuska | eff0e4e | 2015-08-11 00:26:24 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thomas Vachuska | eff0e4e | 2015-08-11 00:26:24 -0700 | [diff] [blame] | 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; |
| 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. |
| 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(); |
| 42 | url = url.replaceFirst("/onos/ui/.*", "/onos/ui/login.html"); |
| 43 | return Response.temporaryRedirect(new URI(url)).build(); |
| 44 | } |
| 45 | |
| 46 | } |