Package mock

Source Code of mock.MockUserManager

/*
* Copyright 2002-2007 the original author or authors.
*
* 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.
*/
package mock;

import javax.servlet.http.HttpServletRequest;
import org.internna.iwebmvc.dao.SecurityDAO;
import org.internna.iwebmvc.model.User;
import org.internna.iwebmvc.model.security.GuestUser;
import org.internna.iwebmvc.security.UserManager;

/**
*
* @author Jose Noheda
*/
public class MockUserManager implements UserManager {

    private SecurityDAO dao;

    private String name = "john";

    public void setName(String name) {
        this.name = name;
    }

    public void setDao(SecurityDAO dao) {
        this.dao = dao;
    }

    @Override public User getActiveUser() {
        return name.equals("guest") ? new GuestUser() : dao.findUser(name);
    }

    @Override public User getActiveUser(HttpServletRequest request) {
        return name.equals("guest") ? new GuestUser() : dao.findUser(name);
    }

    @Override public void refresh() {
        refresh(null);
    }

    @Override public void refresh(HttpServletRequest request) {
        return;
    }

}
TOP

Related Classes of mock.MockUserManager

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.