/***********************************************************
Copyright (C) 2021 VeriSign, Inc.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

http://www.verisign.com/nds/naming/namestore/techdocs.html
 ***********************************************************/

package com.verisign.epp.codec.secureauthinfo.v1_0;

import java.util.LinkedHashSet;
import java.util.Set;

import org.w3c.dom.Element;

import com.verisign.epp.codec.gen.EPPCodecComponent;
import com.verisign.epp.codec.gen.EPPCodecException;
import com.verisign.epp.codec.gen.EPPExtFactory;
import com.verisign.epp.codec.gen.EPPProtocolExtension;
import com.verisign.epp.codec.gen.EPPService;

/**
 * Factory for implementation of the Secure Authorization Information for
 * Transfer Best Common Practice (BCP). This factory is only used to include the
 * Secure Authorization Information for Transfer XML namespace in the greeting
 * and login extension services. No objects will be created by this
 * {@link EPPExtFactory}.
 */
public class EPPSecureAuthInfoExtFactory extends EPPExtFactory {

	/** XML Namespace */
	public static final String NS = "urn:ietf:params:xml:ns:epp:bcp:secure-authinfo-transfer-1.0";

	/**
	 * Service object associated with <code>EPPSecureAuthInfoExtFactory</code>.
	 * The service object is used when creating the Greeting or the Login.
	 */
	private EPPService service;

	/**
	 * Default constructor for <code>EPPSecureAuthInfoExtFactory</code>.
	 */
	public EPPSecureAuthInfoExtFactory() {
		service = new EPPService(null, NS);
		service.setServiceType(EPPService.EXT_SERVICE);
	}

	/**
	 * Creates a concrete <code>EPPCodecComponent</code> from an XML element that
	 * represents an EPP extension.
	 *
	 * @param aExtensionElm
	 *           Extension XML element.
	 *
	 * @return Concrete <code>EPPCodecComponent</code> associated with the
	 *         extension XML element.
	 *
	 * @exception EPPCodecException
	 *               Error creating the concrete <code>EPPCodecComponent</code>
	 */
	public EPPCodecComponent createExtension(Element aExtensionElm) throws EPPCodecException {
		throw new EPPCodecException(
		      "EPPSecureAuthInfoExtFactory.createProtocolExtension: Factory is used ony as a marker for the extension services.");
	}

	/**
	 * Creates a concrete <code>EPPProtocolExtension</code> from an XML element
	 * that represents an EPP protocol extension.
	 *
	 * @param aExtensionElm
	 *           extension XML element.
	 *
	 * @return Concrete <code>EPPProtocolExtension</code> associated with the
	 *         extension XML element.
	 *
	 * @exception EPPCodecException
	 *               Error creating the concrete
	 *               <code>EPPProtocolExtension</code>
	 */
	public EPPProtocolExtension createProtocolExtension(Element aExtensionElm) throws EPPCodecException {
		throw new EPPCodecException(
		      "EPPSecureAuthInfoExtFactory.createProtocolExtension: Protocol extensions not supported");
	}

	/**
	 * Gets the service information associated with the concrete
	 * <code>EPPExtFactory</code>. The service information is used by
	 * <code>EPPFactory</code> for extracting the XML namespace associated with
	 * the extension factory.
	 *
	 * @return service description associated with the concrete
	 *         <code>EPPExtFactory</code>.
	 */
	public EPPService getService() {
		return service;
	}

	/**
	 * Gets the list of XML schemas that need to be pre-loaded into the XML
	 * Parser.
	 *
	 * @return Empty <code>Set</code> since factory is only used as a marker for
	 *         the extension services.
	 *
	 *
	 * @see com.verisign.epp.codec.gen.EPPMapFactory#getXmlSchemas()
	 */
	public Set getXmlSchemas() {
		// Empty Set, since there is no XML schema.
		return new LinkedHashSet();
	}

}
