/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed 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 cdac.medinfo.sdk.dcm30_04.services.tls.commons;

import java.security.SecureRandom;

import javax.net.ssl.KeyManager;
import javax.net.ssl.TrustManager;


/**
 * This class used to specify configuration of TLS server.
 */
public class TLSServerConfig 
{

	private KeyManager[] KeyManagers  = null ;
	private TrustManager[] TrustManagers = null ;
	private String[] EnabledCipherSuites = null;
	private boolean NeedClientAuth = false ;
	private boolean WantClientAuth = false ;
	private SecureRandom objSecureRandom = null ;
	
	
	

	/**
	 * Returns instance of SecureRandom used for TLS authentication.
	 * @return the objSecureRandom instance of SecureRandom
	 */
	public SecureRandom getSecureRandom() 
	{
		return objSecureRandom;
	}
	
	/**
	 * Returns SecureRandom used for TLS authentication.
	 * @param objSecureRandom instance of SecureRandom
	 */
	public void setSecureRandom(SecureRandom objSecureRandom) 
	{
		this.objSecureRandom = objSecureRandom;
	}
	
	
	/**
	 * Returns array of KeyManagers responsible for managing the key material which is used to authenticate the
	 * local Secure Socket to its peer. If no key material is available, the socket will be unable to present 
	 * authentication credentials.
	 * @return the keyManagers
	 */
	public KeyManager[] getKeyManagers() 
	{
		return KeyManagers;
	}
	/**
	 * sets array of KeyManagers responsible for managing the key material which is used to authenticate the 
	 * local Secure Socket to its peer. If no key material is available, the socket will be unable to present
	 * authentication credentials.
	 * @param keyManagers the keyManagers to set
	 */
	public void setKeyManagers(KeyManager[] keyManagers)
	{
		KeyManagers = keyManagers;
	}
	/**
	 * Returns true if the socket to require client authentication else false. 
	 * @return the needClientAuth
	 */
	public boolean isNeedClientAuth()
	{
		return NeedClientAuth;
	}
	/**
	 * sets Configures the socket to require client authentication. This option is only
	 * useful for sockets in the server mode. 
	 * @param bneedClientAuth - set to true if client authentication is required, or false if no client authentication is desired
	 */
	public void setNeedClientAuth(boolean bneedClientAuth) 
	{
		NeedClientAuth = bneedClientAuth;
	}

	/**
	 * Returns array of TrustManagers is responsible for managing the trust material that is used when making 
	 * trust decisions, and for deciding whether credentials presented by a peer should be accepted for secure
	 * communication.
	 * @return the trustManagers
	 */
	public TrustManager[] getTrustManagers() 
	{
		return TrustManagers;
	}
	/**
	 * sets array of TrustManagers is responsible for managing the trust material that is used when making trust 
	 * decisions, and for deciding whether credentials presented by a peer should be accepted for secure 
	 * communication.
	 * @param trustManagers the trustManagers to set
	 */
	public void setTrustManagers(TrustManager[] trustManagers) 
	{
		TrustManagers = trustManagers;
	}
	/**
	 * Returns true if client authentication is requested, or false if no client authentication is desired.
	 * @return the wantClientAuth
	 */
	public boolean isWantClientAuth() 
	{
		return WantClientAuth;
	}
	/**
	 * Configures the socket to request client authentication. This option is only useful for sockets in the server mode.
	 * @param bwantClientAuth set to true if client authentication is requested, or false if no client authentication is desired.
	 */
	public void setWantClientAuth(boolean bwantClientAuth)
	{
		WantClientAuth = bwantClientAuth;
	}
	/**
	 * Returns the names of the cipher suites which could be enabled for use on this connection. Normally, 
	 * only a subset of these will actually be enabled by default, since this list may include cipher suites 
	 * which do not meet quality of service requirements for those defaults. Such cipher suites might be 
	 * useful in specialized applications. 
	 * @return the enabledCipherSuites an array of cipher suite names
	 */
	public String[] getEnabledCipherSuites() 
	{
		return EnabledCipherSuites;
	}
	
	/**
	 * Sets the cipher suites enabled for use on this connection. 
	 * @param enabledCipherSuites   Names of all the cipher suites to enable.
	 */
	public void setEnabledCipherSuites(String[] enabledCipherSuites) 
	{
		EnabledCipherSuites = enabledCipherSuites;
	}

}
