///*
// * ********************************************************************************************************************
// *
// *                      :*$@@%$*:                         ;:                ;;    ;;
// *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
// *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
// *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
// *                   =@*                                  %!              @ $= % %@=   =%@!      %=
// *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
// *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
// *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
// *          $@*   ;@@@%=!:                *@*
// *          =@$    ;;;!=%@@@@=!           =@!
// *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
// *            ;%@@$=$@@%*       *@@@$=%@@%;
// *               ::;::             ::;::                                              All rights reserved.
// *
// * ********************************************************************************************************************
// */
//
//package com.persagy.server.sso
//
//import org.apache.shiro.authc.AuthenticationInfo
//import org.apache.shiro.authc.AuthenticationToken
//import org.apache.shiro.authc.SimpleAuthenticationInfo
//import org.apache.shiro.authz.AuthorizationInfo
//import org.apache.shiro.authz.SimpleAuthorizationInfo
//import org.apache.shiro.realm.AuthorizingRealm
//import org.apache.shiro.subject.PrincipalCollection
//import org.slf4j.LoggerFactory
//
//class UserRealm : AuthorizingRealm() {
//    companion object {
//        // 日志
//        private val logger = LoggerFactory.getLogger(UserRealm::class.java)
//    }
//
//    /**
//     * 获得授权信息
//     */
//    override fun doGetAuthorizationInfo(principals: PrincipalCollection): AuthorizationInfo? {
//        logger.trace("授权")
//        val username = principals.primaryPrincipal
//        var authorizationInfo: SimpleAuthorizationInfo?  = null
//        try {
//            authorizationInfo = SimpleAuthorizationInfo()
////            User user = userService.findByUsername(username);
////            authorizationInfo.addRole(user.getRole().getCode());
////            List<Permission> list = user.getRole().getPermissionList();
////            for(Permission p:list){
////                authorizationInfo.addStringPermission(p.getCode());
////            }
//        } catch (e: Exception) {
//            e.printStackTrace()
//        }
//        return authorizationInfo
//    }
//
//    /**
//     * 获得认证信息
//     */
//    override fun doGetAuthenticationInfo(token: AuthenticationToken): AuthenticationInfo {
//        val username = token.principal as String
////        User user = userService.findByUsername(username);
////        if(user == null) {
////            throw new UnknownAccountException(); // 没找到帐号
////        }
//
//        /*if(Boolean.TRUE.equals(user.getLocked())) {
//            throw new LockedAccountException(); //帐号锁定
//        }*/
//
//        //交给AuthenticatingRealm使用CredentialsMatcher进行密码匹配，如果觉得人家的不好可以在此判断或自定义实现
//        val authenticationInfo = SimpleAuthenticationInfo(
//                username, //用户名
//                "password", //密码
//                name  //realm name
//        )
//
//        return authenticationInfo
//    } // Function doGetAuthenticationInfo()
//} // Class UserRealm
