package com.cm.common.config.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: OauthClientProperties
 * @Description: oauth客户端
 * @Author: WangGeng
 * @Date: 2019-08-19 15:24
 * @Version: 1.0
 **/
@Component
@ConfigurationProperties(prefix = "security.oauth2.client")
public class OauthClientProperties {
    private String clientId;
    private String clientSecret;
    private String userAuthorizationUri;
    private String accessTokenUri;
    private String grantType;

    public String getClientId() {
        return clientId == null ? "" : clientId.trim();
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public String getClientSecret() {
        return clientSecret == null ? "" : clientSecret.trim();
    }

    public void setClientSecret(String clientSecret) {
        this.clientSecret = clientSecret;
    }

    public String getUserAuthorizationUri() {
        return userAuthorizationUri == null ? "" : userAuthorizationUri.trim();
    }

    public void setUserAuthorizationUri(String userAuthorizationUri) {
        this.userAuthorizationUri = userAuthorizationUri;
    }

    public String getAccessTokenUri() {
        return accessTokenUri == null ? "" : accessTokenUri.trim();
    }

    public void setAccessTokenUri(String accessTokenUri) {
        this.accessTokenUri = accessTokenUri;
    }

    public String getGrantType() {
        return grantType == null ? "" : grantType.trim();
    }

    public void setGrantType(String grantType) {
        this.grantType = grantType;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"clientId\":")
                .append("\"").append(clientId).append("\"");
        sb.append(",\"clientSecret\":")
                .append("\"").append(clientSecret).append("\"");
        sb.append(",\"userAuthorizationUri\":")
                .append("\"").append(userAuthorizationUri).append("\"");
        sb.append(",\"accessTokenUri\":")
                .append("\"").append(accessTokenUri).append("\"");
        sb.append(",\"grantType\":")
                .append("\"").append(grantType).append("\"");
        sb.append('}');
        return sb.toString();
    }
}
