edu.uiowa.icts.bluebutton.controller.AbstractBluebuttonController.java Source code

Java tutorial

Introduction

Here is the source code for edu.uiowa.icts.bluebutton.controller.AbstractBluebuttonController.java

Source

package edu.uiowa.icts.bluebutton.controller;

/*
 * #%L
 * blue-button Spring MVC Web App
 * %%
 * Copyright (C) 2014 - 2015 University of Iowa Institute for Clinical and Translational Science (ICTS)
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.ModelAttribute;

import edu.uiowa.icts.bluebutton.dao.BluebuttonDaoService;
import edu.uiowa.icts.bluebutton.domain.Person;

/**
 * Generated by Protogen
 * @since Thu Jul 31 09:37:03 CDT 2014
 */
public abstract class AbstractBluebuttonController {

    private static final Log log = LogFactory.getLog(AbstractBluebuttonController.class);

    protected BluebuttonDaoService bluebuttonDaoService;

    @Autowired
    public void setBluebuttonDaoService(BluebuttonDaoService bluebuttonDaoService) {
        this.bluebuttonDaoService = bluebuttonDaoService;
    }

    @ModelAttribute("username")
    public String getUsername() {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        if (auth != null) {
            return auth.getName();
        }
        return "anonymousUser";
    }

}