All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.eworkcloud.dns.DnsConfiguration Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
package com.eworkcloud.dns;

import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;

@Configuration
public class DnsConfiguration implements EnvironmentAware {

    private static Environment environment;
    private static String endpoint;
    private static String accessKey;
    private static String secretKey;

    @Override
    public void setEnvironment(Environment environment) {
        DnsConfiguration.environment = environment;
    }

    /**
     * 获取访问端点
     *
     * @return 访问端点
     */
    public static String getEndpoint() {
        if (null == environment || StringUtils.hasText(endpoint)) {
            return endpoint;
        }
        return environment.getProperty("dns.endpoint");
    }

    /**
     * 设置访问端点
     *
     * @param endpoint 访问端点
     */
    public static void setEndpoint(String endpoint) {
        DnsConfiguration.endpoint = endpoint;
    }

    /**
     * 获取访问钥匙
     *
     * @return 访问钥匙
     */
    public static String getAccessKey() {
        if (null == environment || StringUtils.hasText(accessKey)) {
            return accessKey;
        }
        return environment.getProperty("dns.accessKey");
    }

    /**
     * 设置访问钥匙
     *
     * @param accessKey 访问钥匙
     */
    public static void setAccessKey(String accessKey) {
        DnsConfiguration.accessKey = accessKey;
    }

    /**
     * 获取安全密钥
     *
     * @return 安全密钥
     */
    public static String getSecretKey() {
        if (null == environment || StringUtils.hasText(secretKey)) {
            return secretKey;
        }
        return environment.getProperty("dns.secretKey");
    }

    /**
     * 设置安全密钥
     *
     * @param secretKey 安全密钥
     */
    public static void setSecretKey(String secretKey) {
        DnsConfiguration.secretKey = secretKey;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy