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

com.freedomotic.plugins.devices.restapiv3.auth.FDWebEnvironment Maven / Gradle / Ivy

The newest version!
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.freedomotic.plugins.devices.restapiv3.auth;

import com.freedomotic.plugins.devices.restapiv3.RestAPIv3;
import com.freedomotic.plugins.devices.restapiv3.filters.CorsBasicHttpAuthenticationFilter;
import org.apache.shiro.web.env.DefaultWebEnvironment;
import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
import org.apache.shiro.web.filter.authc.LogoutFilter;
import org.apache.shiro.web.filter.mgt.DefaultFilterChainManager;
import org.apache.shiro.web.filter.mgt.FilterChainManager;
import org.apache.shiro.web.filter.mgt.PathMatchingFilterChainResolver;

/**
 *
 * @author matteo
 */
public class FDWebEnvironment extends DefaultWebEnvironment {

    public FDWebEnvironment() {
        BasicHttpAuthenticationFilter authc = new CorsBasicHttpAuthenticationFilter();
        LogoutFilter logout = new LogoutFilter();
        logout.setRedirectUrl("http://www.freedomotic.com/");
        
        FilterChainManager fcMan = new DefaultFilterChainManager();
        fcMan.addFilter("authc", authc);
        fcMan.addFilter("logout", logout);
        fcMan.createChain("/auth/logout", "logout");
        fcMan.createChain("/v3/**", "authc");

        PathMatchingFilterChainResolver resolver = new PathMatchingFilterChainResolver();
        resolver.setFilterChainManager(fcMan);

        setFilterChainResolver(resolver);
        setWebSecurityManager(RestAPIv3.defaultWebSecurityManager);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy