001    package org.jboss.dna.graph;
002    
003    /**
004     * A security context provides a pluggable means to support disparate authentication and authorization 
005     * mechanisms that specify the user name and roles.
006     * <p>
007     * A security context should only be associated with the execution context <b>after</b> authentication has occurred.
008     * </p>
009     */
010    public interface SecurityContext {
011    
012        /**
013         * Returns the authenticated user's name
014         * 
015         * @return the authenticated user's name
016         */
017        String getUserName();
018    
019        /**
020         * Returns whether the authenticated user has the given role.
021         * 
022         * @param roleName the name of the role to check
023         * @return true if the user has the role and is logged in; false otherwise
024         */
025        boolean hasRole( String roleName );
026        
027        /**
028         * Logs the user out of the authentication mechanism.
029         * <p>
030         * For some authentication mechanisms, this will be implemented as a no-op.
031         * </p>
032         */
033        void logout();
034        
035    }