/*
 * Copyright 2002 Tryllian BV and Otto Moerbeek
 * http://www.tryllian.com
 * otto@tryllian.com
 */

package net.drijf.javaone;

import java.util.Map;

/**
 * This class implements a basic role mapping, using a memory based
 * table. In real life, one would do this mapping based on property
 * files ar a database.
 *
 * @author Otto Moerbeek
 */
public class RoleMappingImpl implements RoleMapping
{
    /** The table of name to role mappings. */
    private Map roledefs;

    /** 
     * Construct a new role mapping, based on a map.
     * @param roledefs a map containing name to role mappings.
     */
    public RoleMappingImpl(Map roledefs) {
        this.roledefs = roledefs;
    }
   
    /**
     * Return the role associated with a name.
     * @param alias the name the return a role for.
     * @return the role associated with the name, or <code>null</code> if
     * the name is unknown.
     */
    public Role getRole(String alias) {
        return (Role) roledefs.get(alias);
    }
}
