Java tutorial
/* Copyright (C) 2007 Flix Garca Borrego (borrego at gmail.com) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 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 Library General Public License for more details. You should have received a copy of the GNU Library 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 */ package org.viafirma.cliente.openid; import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.viafirma.cliente.util.Constantes; import org.openid4java.consumer.ConsumerException; /** * Crea una nueva instancia de un manejador OpenID * @author Felix Garcia Borrego (borrego at gmail.com) */ public class OpenIdHandlerFactory { private static Log log = LogFactory.getLog(OpenIdHandlerFactory.class); /** * Crea una nueva instancia del Manejador OpenId utilizando los parametros indicados * @param propiedades * @return */ public static OpenIdHandler build(Properties propiedades) { try { // recuperamos la url de retorno de autenticacin String urlAplicacion = propiedades.getProperty(Constantes.PARAM_URL_APLICACION); if (urlAplicacion == null) { log.fatal("El cliente OpenId No ha podido ser inicializado, Falta el parametro " + Constantes.PARAM_URL_APLICACION); throw new ExceptionInInitializerError( "El cliente OpenId No ha podido ser inicializado, Falta el parametro " + Constantes.PARAM_URL_APLICACION); } else { log.debug("Nuevo cliente OpenID con url de retorno para la autenticacin OpenId:" + urlAplicacion); // inicializo la instancia return new OpenIdHandler(urlAplicacion); } // asigno la instancia generada como instancia singleton. } catch (ConsumerException e) { log.fatal("El cliente OpenId No ha podido ser inicializado.", e); throw new ExceptionInInitializerError( "El cliente OpenId No ha podido ser inicializado." + e.getMessage()); } } }