/* * Atricore IDBus * * Copyright (c) 2009, Atricore Inc. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.atricore.idbus.capabilities.josso.main; import org.apache.camel.CamelContext; import org.apache.camel.Endpoint; import org.apache.camel.impl.DefaultComponent; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.atricore.idbus.capabilities.josso.main.endpoints.*; import org.atricore.idbus.kernel.main.mediation.camel.AbstractCamelEndpoint; import java.util.Map; /** * @author <a href="mailto:sgonzalez@atricore.org">Sebastian Gonzalez Oyuela</a> * @version $Id$ */ public class JossoComponent extends DefaultComponent { private static final Log logger = LogFactory.getLog( JossoComponent.class ); public JossoComponent() { } public JossoComponent( CamelContext context ) { super( context ); } protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { logger.debug("Creating Camel Endpoint for [" + uri + "] [" + remaining + "]"); AbstractCamelEndpoint endpoint; JossoService e = getJosso11Service( remaining ); switch ( e ) { case SingleSignOnService: endpoint = new SingleSignOnEndpoint(uri, this, parameters); break; case SingleLogoutService: endpoint = new SingleLogoutEndpoint( uri, this, parameters ); break; case AssertionConsumerService: endpoint = new AssertionConsumerEndpoint( uri, this, parameters ); break; case IdentityManager: endpoint = new IdentityManagerEndpoint( uri, this, parameters); break; case IdentityProvider: endpoint = new IdentityProviderEndpoint( uri, this, parameters); break; case SessionManager: endpoint = new SessionManagerEndpoint( uri, this, parameters); break; default: throw new IllegalArgumentException( "Unsupported JOSSO 1.x service type " + remaining ); } endpoint.setAction( remaining ); setProperties( endpoint, parameters ); return endpoint; } protected JossoService getJosso11Service(String remaining) { // TODO : do not ignore the quallified name! for (JossoService et : JossoService.values()) { if (et.getQname().getLocalPart().equals(remaining)) return et; } throw new IllegalArgumentException( "Invalid JOSSO 1.x service type " + remaining ); } }