// Path: sso-client-demo/sso-client-shiro-demo/src/main/java/com/carl/auth/shiro/client/demo/core/ClientStrategy.java
// public interface ClientStrategy {
//     /**
//      * clientName
//      *
//      * @return
//      */
//     String name();
// 
//     /**
//      * 若匹配出则进行终端处理
//      *
//      * @param joinPoint
//      * @param pac4jPrincipal
//      */
//     void handle(JoinPoint joinPoint, Pac4jPrincipal pac4jPrincipal) throws Exception;
// 
// 
//     /**
//      * 判断是否已绑定
//      *
//      * @param principal
//      * @return
//      */
//     boolean isBind(Pac4jPrincipal principal);
// }
// 
// Path: sso-client-demo/sso-client-shiro-demo/src/main/java/com/carl/auth/shiro/client/demo/core/PrincipalBindResolver.java
// public interface PrincipalBindResolver {
//     /**
//      * 判断用户是否已经绑定
//      *
//      * @param id
//      * @return
//      */
//     boolean isBind(String id);
// 
//     /**
//      * 把当前用户绑定到实际的用户数
//      *
//      * @param principal 当前用户
//      * @param user      目标用户
//      */
//     void bind(Pac4jPrincipal principal, Object user) throws Exception;
// }
// 
// Path: sso-client-demo/sso-client-shiro-demo/src/main/java/com/carl/auth/shiro/client/demo/exception/NotBindException.java
// public class NotBindException extends Exception {
//     private String clientName;
//     private String redirectUrl;
//     private Map<String, Object> attr;
//     private Pac4jPrincipal principal;
// 
//     public Pac4jPrincipal getPrincipal() {
//         return principal;
//     }
// 
//     public NotBindException setPrincipal(Pac4jPrincipal principal) {
//         this.principal = principal;
//         return this;
//     }
// 
//     public String getClientName() {
//         return clientName;
//     }
// 
//     public NotBindException setClientName(String clientName) {
//         this.clientName = clientName;
//         return this;
//     }
// 
//     public String getRedirectUrl() {
//         return redirectUrl;
//     }
// 
//     public NotBindException setRedirectUrl(String redirectUrl) {
//         this.redirectUrl = redirectUrl;
//         return this;
//     }
// 
//     public Map<String, Object> getAttr() {
//         return attr;
//     }
// 
//     public NotBindException setAttr(Map<String, Object> attr) {
//         this.attr = attr;
//         return this;
//     }
// }


import com.carl.auth.shiro.client.demo.core.ClientStrategy;
import com.carl.auth.shiro.client.demo.core.PrincipalBindResolver;
import com.carl.auth.shiro.client.demo.exception.NotBindException;
import io.buji.pac4j.subject.Pac4jPrincipal;
import org.aspectj.lang.JoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
 * 版权所有.(c)2008-2017. 卡尔科技工作室
 */

/*
 * 版权所有.(c)2008-2017. 卡尔科技工作室
 */

package com.carl.auth.shiro.client.demo.core.github;


/**
 * github处理策略
 *
 * @author Carl
 * @date 2017/10/8
 * @since 1.5.0
 */
public class GitHubClientStrategy implements ClientStrategy {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    //用户绑定决定
    private PrincipalBindResolver resolver;

    public GitHubClientStrategy(PrincipalBindResolver resolver) {
        this.resolver = resolver;
    }

    @Override
    public String name() {
        return "github";
    }

    @Override
// Path: sso-client-demo/sso-client-shiro-demo/src/main/java/com/carl/auth/shiro/client/demo/core/ClientStrategy.java
// public interface ClientStrategy {
//     /**
//      * clientName
//      *
//      * @return
//      */
//     String name();
// 
//     /**
//      * 若匹配出则进行终端处理
//      *
//      * @param joinPoint
//      * @param pac4jPrincipal
//      */
//     void handle(JoinPoint joinPoint, Pac4jPrincipal pac4jPrincipal) throws Exception;
// 
// 
//     /**
//      * 判断是否已绑定
//      *
//      * @param principal
//      * @return
//      */
//     boolean isBind(Pac4jPrincipal principal);
// }
// 
// Path: sso-client-demo/sso-client-shiro-demo/src/main/java/com/carl/auth/shiro/client/demo/core/PrincipalBindResolver.java
// public interface PrincipalBindResolver {
//     /**
//      * 判断用户是否已经绑定
//      *
//      * @param id
//      * @return
//      */
//     boolean isBind(String id);
// 
//     /**
//      * 把当前用户绑定到实际的用户数
//      *
//      * @param principal 当前用户
//      * @param user      目标用户
//      */
//     void bind(Pac4jPrincipal principal, Object user) throws Exception;
// }
// 
// Path: sso-client-demo/sso-client-shiro-demo/src/main/java/com/carl/auth/shiro/client/demo/exception/NotBindException.java
// public class NotBindException extends Exception {
//     private String clientName;
//     private String redirectUrl;
//     private Map<String, Object> attr;
//     private Pac4jPrincipal principal;
// 
//     public Pac4jPrincipal getPrincipal() {
//         return principal;
//     }
// 
//     public NotBindException setPrincipal(Pac4jPrincipal principal) {
//         this.principal = principal;
//         return this;
//     }
// 
//     public String getClientName() {
//         return clientName;
//     }
// 
//     public NotBindException setClientName(String clientName) {
//         this.clientName = clientName;
//         return this;
//     }
// 
//     public String getRedirectUrl() {
//         return redirectUrl;
//     }
// 
//     public NotBindException setRedirectUrl(String redirectUrl) {
//         this.redirectUrl = redirectUrl;
//         return this;
//     }
// 
//     public Map<String, Object> getAttr() {
//         return attr;
//     }
// 
//     public NotBindException setAttr(Map<String, Object> attr) {
//         this.attr = attr;
//         return this;
//     }
// }


// Path: sso-client-demo/sso-client-shiro-demo/src/main/java/com/carl/auth/shiro/client/demo/core/github/GitHubClientStrategy.java
import com.carl.auth.shiro.client.demo.core.ClientStrategy;
import com.carl.auth.shiro.client.demo.core.PrincipalBindResolver;
import com.carl.auth.shiro.client.demo.exception.NotBindException;
import io.buji.pac4j.subject.Pac4jPrincipal;
import org.aspectj.lang.JoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/*
 * 版权所有.(c)2008-2017. 卡尔科技工作室
 */

/*
 * 版权所有.(c)2008-2017. 卡尔科技工作室
 */

package com.carl.auth.shiro.client.demo.core.github;


/**
 * github处理策略
 *
 * @author Carl
 * @date 2017/10/8
 * @since 1.5.0
 */
public class GitHubClientStrategy implements ClientStrategy {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    //用户绑定决定
    private PrincipalBindResolver resolver;

    public GitHubClientStrategy(PrincipalBindResolver resolver) {
        this.resolver = resolver;
    }

    @Override
    public String name() {
        return "github";
    }

    @Override
    public void handle(JoinPoint joinPoint, Pac4jPrincipal pac4jPrincipal) throws Exception {