package com.qmth.teachcloud.cas.util.sxufe;

import com.qmth.teachcloud.exchange.common.contant.SystemConstant;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class CasUtils {

    /**
     * 获取TargetUrl
     */
    public static String getTargetUrl() {
        String basePath = SystemConstant.getBasePath();
        // 使用默认页面作为targetUrl
        return basePath + Constants.DEF_TARGET_URI;
    }

    /**
     * 获取登出地址
     */
    public static String getLogoutUrl() throws UnsupportedEncodingException {
        // 获取本次请求的根Path
        String loginUrlRoot = SystemConstant.getBasePath() + Constants.SSO_LOGIN_URI;
        String encodeLoginUrlRoot = URLEncoder.encode(loginUrlRoot, SystemConstant.CHARSET_NAME);
        return Constants.CAS_LOGOUT_URL + SystemConstant.GET_UNKNOWN + SystemConstant.SERVICE_KEY + SystemConstant.GET_EQUAL + encodeLoginUrlRoot;
    }
}
