/** * Copyright (C) 2010-2017 Structr GmbH * * This file is part of Structr <http://structr.org>. * * Structr is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * Structr is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Structr. If not, see <http://www.gnu.org/licenses/>. */ package org.structr.web.resource; import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.structr.common.SecurityContext; import org.structr.common.error.FrameworkException; import org.structr.core.Result; import org.structr.core.property.PropertyKey; import org.structr.rest.RestMethodResult; import org.structr.rest.exception.NotAllowedException; import org.structr.rest.resource.Resource; //~--- classes ---------------------------------------------------------------- /** * Resource that handles logs a user out * * */ public class LogoutResource extends Resource { //~--- methods -------------------------------------------------------- @Override public boolean checkAndConfigure(String part, SecurityContext securityContext, HttpServletRequest request) { this.securityContext = securityContext; if (getUriPart().equals(part)) { return true; } return false; } @Override public RestMethodResult doPost(Map<String, Object> propertySet) throws FrameworkException { securityContext.getAuthenticator().doLogout(securityContext.getRequest()); return new RestMethodResult(200); } @Override public Result doGet(PropertyKey sortKey, boolean sortDescending, int pageSize, int page, String offsetId) throws FrameworkException { throw new NotAllowedException("GET not allowed on " + getResourceSignature()); } @Override public RestMethodResult doPut(Map<String, Object> propertySet) throws FrameworkException { throw new NotAllowedException("PUT not allowed on " + getResourceSignature()); } @Override public RestMethodResult doDelete() throws FrameworkException { throw new NotAllowedException("DELETE not allowed on " + getResourceSignature()); } @Override public RestMethodResult doOptions() throws FrameworkException { throw new NotAllowedException("OPTIONS not allowed on " + getResourceSignature()); } @Override public Resource tryCombineWith(Resource next) throws FrameworkException { return null; } // ----- private methods ----- //~--- get methods ---------------------------------------------------- @Override public Class getEntityClass() { return null; } @Override public String getUriPart() { return "logout"; } @Override public String getResourceSignature() { return "_logout"; } @Override public boolean isCollectionResource() { return false; } }