blob: 745d551c031f7b9852695a9eeb2cc61441ed88d6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/*******************************************************************************
* Copyright (c) 2013 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.account.rest.internal;
import javax.annotation.security.RolesAllowed;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import org.eclipse.osee.account.admin.SystemRoles;
import org.eclipse.osee.account.rest.model.AccountSessionData;
/**
* @author Roberto E. Escobar
*/
public class AccountLogoutResource {
private final AccountOps accountOps;
public AccountLogoutResource(AccountOps accountOps) {
this.accountOps = accountOps;
}
/**
* Logs user out of the system
*
* @return response
* @response.representation.200.doc successfully logged out
* @response.representation.304.doc session not modified
*/
@POST
@RolesAllowed(SystemRoles.ROLES_AUTHENTICATED)
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response logout(AccountSessionData data) {
ResponseBuilder builder;
boolean modified = accountOps.doLogout(data.getToken());
if (modified) {
builder = Response.ok();
} else {
builder = Response.notModified();
}
return builder.build();
}
}
|