All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.seedstack.w20.rest.security.BasicAuthenticationResource Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
 *
 * This file is part of SeedStack, An enterprise-oriented full development stack.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package org.seedstack.w20.rest.security;


import org.seedstack.seed.security.api.SecuritySupport;

import javax.inject.Inject;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;

@Path("/seed-w20/security/basic-authentication")
public class BasicAuthenticationResource {
    @Inject
    SecuritySupport securitySupport;

    @GET
    public Response authenticate() {
        if (!securitySupport.isAuthenticated()) {
            return Response.status(Response.Status.FORBIDDEN).build();
        }

        return Response.status(Response.Status.NO_CONTENT).build();
    }

    @DELETE
    public Response deauthenticate() {
        securitySupport.logout();

        return Response.status(Response.Status.NO_CONTENT).build();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy