Search in sources :

Example 1 with MCRSystemUserInformation

use of org.mycore.common.MCRSystemUserInformation in project mycore by MyCoRe-Org.

the class MCRAccessBaseImpl method checkPermission.

/*
     * (non-Javadoc)
     * 
     * @see org.mycore.access.MCRAccessInterface#checkAccess(java.lang.String,
     *      java.lang.String)
     */
public boolean checkPermission(String id, String permission) {
    LOGGER.debug("Execute MCRAccessBaseImpl checkPermission for ID {} for permission {}", id, permission);
    long start = System.currentTimeMillis();
    try {
        MCRAccessRule rule = getAccessRule(id, permission);
        if (rule == null) {
            LOGGER.debug("No rule defined. Checking if current user is super user.");
            MCRSystemUserInformation superUserInstance = MCRSystemUserInformation.getSuperUserInstance();
            String superUserID = superUserInstance.getUserID();
            return superUserID.equals(MCRSessionMgr.getCurrentSession().getUserInformation().getUserID());
        }
        boolean validate = rule.validate();
        LOGGER.debug(validate ? "Current user has permission." : "Current user does not have permission.");
        return validate;
    } finally {
        LOGGER.debug("Check {} on {} took:{}", permission, id, System.currentTimeMillis() - start);
    }
}
Also used : MCRSystemUserInformation(org.mycore.common.MCRSystemUserInformation)

Aggregations

MCRSystemUserInformation (org.mycore.common.MCRSystemUserInformation)1