package me.chyxion.tigon.shiro;

import java.util.Collection;
import java.util.Collections;
import me.chyxion.tigon.shiro.model.Credential;
import org.apache.shiro.authc.AuthenticationToken;

/**
 * @version 0.0.1
 * @since 0.0.1
 * @author Shaun Chyxion <br>
 * chyxion@163.com <br>
 * Apr 7, 2015 3:14:55 PM
 */
public abstract class AuthRealm {

    /**
     * @param principal principal
     * @return roles
     */
    public Collection<String> roles(Object principal) {
        return Collections.emptyList();
    }

    /**
     * @param principal principal
     * @return permissions
     */
    public Collection<String> permissions(Object principal) {
        return Collections.emptyList();
    }

    /**
     * @param principal principal
     * @return credential
     */
    public abstract Credential credential(Object principal);

    /**
     * for override
     * @param principal principal
     * @param authToken auth token
     * @return credential
     */
    public Credential credential(Object principal, AuthenticationToken authToken) {
        return credential(principal);
    }


    /**
     * @param password password
     * @param credential credential
     * @return true if credential matched
     */
    public abstract boolean credentialMatch(Object password, Credential credential); 
}
