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

org.nervousync.proxy.AbstractProxyConfigBuilder Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
/*
 * Licensed to the Nervousync Studio (NSYC) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.nervousync.proxy;

import org.nervousync.builder.AbstractBuilder;
import org.nervousync.security.factory.SecureFactory;

import java.net.Proxy;

/**
 * 

Abstract proxy configure builder for Generics Type

*

* Current abstract class is using to integrate to another builder * which configure contains proxy configure information. *

*

拥有父构造器的代理服务器配置信息抽象构造器

*

当前抽象构建器用于整合到包含代理服务器配置信息的其他配置构建器

* * @param Generics Type Class * 泛型类 * * @author Steven Wee [email protected] * @version $Revision: 1.0.0 $ $Date: Jan 4, 2019 16:22:54 $ */ public abstract class AbstractProxyConfigBuilder extends AbstractBuilder { /** * New secure name * 新的安全名称 */ private final String secureName; /** * Proxy configure information * 代理服务器配置信息 */ protected final ProxyConfig proxyConfig; /** *

Protected constructor for AbstractProxyConfigBuilder

*

AbstractProxyConfigBuilder的构造函数

* * @param parentBuilder Generics Type instance * 泛型类实例对象 * @param secureName New secure name * 新的安全名称 * @param proxyConfig Proxy configure information * 代理服务器配置信息 */ protected AbstractProxyConfigBuilder(final T parentBuilder, final String secureName, final ProxyConfig proxyConfig) { super(parentBuilder); this.secureName = secureName; this.proxyConfig = proxyConfig; } /** *

Configure proxy type

*

配置代理服务器类型

* * @param proxyType Enumeration value of proxy server * 代理服务器类型枚举值 * * @return Current builder instance * 当前构造器实例对象 */ public final AbstractProxyConfigBuilder proxyType(final Proxy.Type proxyType) { this.proxyConfig.setProxyType(proxyType); return this; } /** *

Configure proxy server information

*

配置代理服务器信息

* * @param serverAddress Proxy server address * 代理服务器地址 * @param serverPort Proxy server port * 代理服务器端口号 * * @return Current builder instance * 当前构造器实例对象 */ public final AbstractProxyConfigBuilder serverConfig(final String serverAddress, final int serverPort) { if (!Proxy.Type.DIRECT.equals(this.proxyConfig.getProxyType())) { this.proxyConfig.setProxyAddress(serverAddress); this.proxyConfig.setProxyPort(serverPort); } return this; } /** *

Configure proxy server authenticate information

*

配置代理服务器身份验证信息

* * @param userName Authenticate username * 身份认证用户名 * @param passWord Authenticate password * 身份认证密码 * * @return Current builder instance * 当前构造器实例对象 */ public final AbstractProxyConfigBuilder authenticator(final String userName, final String passWord) { if (!Proxy.Type.DIRECT.equals(this.proxyConfig.getProxyType())) { this.proxyConfig.setUserName(userName); this.proxyConfig.setPassword(SecureFactory.encrypt(this.secureName, passWord)); } return this; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy