配置邮箱

@param host 邮件服务器
@param personal 个人名称
@param from 发件箱
@param key 密码
552489
public static void config(String host, String personal, String from, String key) {
        setHost(host);
        setPersonal(personal);
        setFrom(from);
        setKey(key);
    }
1030876
public static Session getSession(String host, final String username,
                                     final String password) {
        // 设置配置文件，邮件主机和是否认证
        Properties property = new Properties();
        property.put("mail.host", host);
        property.put("mail.smtp.auth", "true");
        // 设置用户名和密码
        Authenticator auth = new Authenticator() {
            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password);
            }
        };
        // 获取与邮件主机的连接
        Session session = Session.getInstance(property, auth);
        return session;
    }
616293
public void setFrom(String address, String personal) throws AddressException {
		from = toInternetAddress(address, personal);
	}
888305
public void setHost(String host) {
		if(isModifiable == ModifiableRule.ContactSystem || isModifiable == ModifiableRule.NotModifiable) {
			throw new IllegalArgumentException("Host part of the URI is not modifiable");
		}
		try {
			getSipURI().setHost(host);
		} catch (ParseException e) {
			logger.error("parse exception occured", e);
			throw new IllegalArgumentException("Bad arg!",e);
		}
	}
223842
static MPApiResponse getFromCache(String key) {
        HashMap<String, MPApiResponse> mapCache = getMapCache();
        MPApiResponse response = null;
        try {
            response = mapCache.get(key).clone();
        } catch (Exception ex) {
            // Do nothing
        }
        if (response != null) {
            response.fromCache = Boolean.TRUE;
        }
        return response;
    }
72047
private void setUserInfo(CmsUser user, String key, String value) {

        if (!CmsStringUtil.isEmptyOrWhitespaceOnly(value)) {
            user.getAdditionalInfo().put(key, value);
        }
    }
1325169
private static Observable<PingServiceHealth> pingQuery(
        final NetworkAddress hostname, final String bucket, final String password,
        final ClusterFacade core, final long timeout, final TimeUnit timeUnit) {
        final AtomicReference<CouchbaseRequest> request = new AtomicReference<CouchbaseRequest>();
        Observable<com.couchbase.client.core.message.query.PingResponse> response =
            Observable.defer(new Func0<Observable<com.couchbase.client.core.message.query.PingResponse>>() {
            @Override
            public Observable<com.couchbase.client.core.message.query.PingResponse> call() {
                CouchbaseRequest r;
                try {
                    r = new com.couchbase.client.core.message.query.PingRequest(
                        InetAddress.getByName(hostname.address()), bucket, password
                    );
                } catch (Exception e) {
                    return Observable.error(e);
                }
                request.set(r);
                return core.send(r);
            }
        }).timeout(timeout, timeUnit);
        return mapToServiceHealth(null, ServiceType.QUERY, response, request, timeout, timeUnit);
    }
1339085
function Embdr(key) {
    if (!(this instanceof Embdr)) {
        return new Embdr(key);
    }

    this._api = {
        'auth': null,
        'host': Embdr.DEFAULT_HOST,
        'port': Embdr.DEFAULT_PORT,
        'basePath': Embdr.DEFAULT_BASE_PATH,
        'protocol': Embdr.DEFAULT_PROTOCOL
    };

    this.setApiKey(key);
    this._exposeApis();
}
1268557
private void checkKey(final String key) {

		/*
		 * Get hashtag from the first host of the active pool We cannot use the
		 * connection object because as of now we have not selected a connection. A
		 * connection is selected based on the key or hashtag respectively.
		 */
		String hashtag = connPool.getConfiguration().getHashtag();
		if (hashtag == null || hashtag.isEmpty()) {
			if (theKey.get() != null) {
				verifyKey(key);
			} else {
				boolean success = theKey.compareAndSet(null, key);
				if (!success) {
					// someone already beat us to it. that's fine, just verify
					// that the key is the same
					verifyKey(key);
				} else {
					pipelined(key);
				}
			}
		} else {
			/*
			 * We have a identified a hashtag in the Host object. That means Dynomite has a
			 * defined hashtag. Producing the hashvalue out of the hashtag and using that as
			 * a reference to the pipeline
			 */
			String hashValue = StringUtils.substringBetween(key, Character.toString(hashtag.charAt(0)),
					Character.toString(hashtag.charAt(1)));
			if (Strings.isNullOrEmpty(hashValue)) {
				hashValue = key;
			}
			checkHashtag(key, hashValue);
		}
	}
121906
public Note createResponse(String name, String content, boolean personal) {
		return getInstance().create().note(this, name, content, personal);
	}
918095
public String formatKey(String host, int port) throws URISyntaxException
	{
		if (port < 1) {
			throw new URISyntaxException("","The port value must be greater than zero");
		}
		
		if (!"".equals(host)) {
			return host + ":" + port;
		} else {
			throw new URISyntaxException("","The host cannot be null");
		}
	}
1111207
SubjectIdentity getSubjectIdentity(final String protocol, final String forHost) {
        KeytabService selectedService = null;

        final String hostName = forHost == null ? null : forHost.toLowerCase(Locale.ENGLISH);
        String name = protocol + "/" + hostName;
        selectedService = hostServiceMap.get(name);
        if (selectedService == null) {
            SECURITY_LOGGER.tracef("No mapping for name '%s' to KeytabService, attempting to use host only match.", name);
            selectedService = hostServiceMap.get(hostName);
            if (selectedService == null) {
                SECURITY_LOGGER.tracef("No mapping for host '%s' to KeytabService, attempting to use default.", forHost);
                selectedService = defaultService;
            }
        }

        if (selectedService != null) {
            if (SECURITY_LOGGER.isTraceEnabled()) {
                SECURITY_LOGGER.tracef("Selected KeytabService with principal '%s' for host '%s'",
                        selectedService.getPrincipal(), forHost);
            }
            try {
                return selectedService.createSubjectIdentity(false);
            } catch (LoginException e) {
                SECURITY_LOGGER.keytabLoginFailed(selectedService.getPrincipal(), forHost, e);
                /*
                 * Allow to continue and return null, i.e. we have an error preventing Kerberos authentication so log that but
                 * other mechanisms may be available leaving the server still accessible.
                 */
            }
        } else {
            SECURITY_LOGGER.tracef("No KeytabService available for host '%s' unable to return SubjectIdentity.", forHost);
        }

        return null;
    }
1087680
public void setHostKeys(java.util.Collection<HostKeyAttributes> hostKeys) {
        if (hostKeys == null) {
            this.hostKeys = null;
            return;
        }

        this.hostKeys = new java.util.ArrayList<HostKeyAttributes>(hostKeys);
    }
343581
public static PrivateKey loadPrivateKeyFromKeyStore(String location,String alias,String storeType,String storePass,String keyPass){
        try {			
        	storeType = null == storeType ? KeyStore.getDefaultType() : storeType;
        	keyPass = keyPass == null ? storePass : keyPass;
        	KeyStore keyStore = KeyStore.getInstance(storeType);
        	InputStream is = new FileInputStream(location);
        	keyStore.load(is, storePass.toCharArray());
        	// 由密钥库获取密钥的两种方式
        	return (PrivateKey) keyStore.getKey(alias, keyPass.toCharArray());
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
    }
302953
public void setHost(String host)
        throws java.net.UnknownHostException
    {
        _addr=null;
        if (host!=null)
        {
            if (host.indexOf('/')>0)
                host=host.substring(0,host.indexOf('/'));
            _addrIsHost=!Character.isDigit((host.charAt(0)));
            _addr=InetAddress.getByName(host);
        }
    }
855512
protected boolean isVirtualDns(Host host) {
		long millis = host.getExpiration() - System.currentTimeMillis();
		// JVM的DNS缓存默认是30秒过期，如果过期时间大于1年则表示自定义的域名解析记录
		// 在要求特别准确的情况下请注意:如果自定义了JVM DNS缓存时间超过1年，则会返回错误数据.
		return (millis > ABOUT_YEAR);
	}
862496
static void addToCache(String key, MPApiResponse response) {
        HashMap<String, MPApiResponse> mapCache = getMapCache();
        mapCache.put(key, response);
    }