/************************************************************************
*
* Copyright (c) 2003-2004, C&C Research Laboratories, NEC Europe Ltd.
*
* Copyright in this library belongs to C&C Research Laboratories,
* Rathausallee 10, 53757 Sankt Augustin, Germany.
*
* This software may not be used, sold, licensed, transferred, copied
* or reproduced in whole or in part in any manner or form or in or
* on any media by any person other than in accordance with the terms
* of the Licence Agreement supplied with the software, or otherwise
* without the prior written consent of the copyright owners.
*
* This software is distributed WITHOUT ANY WARRANTY, without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE, except where stated in the Licence Agreement supplied with
* the software.
*
*  Created By :           Federico Crazzolara
*  Created for Project :  GEMSS (IST-2001-37153)
*
************************************************************************/



/**
 * TokenServiceLocator.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis WSDL2Java emitter.
 *
 *
 * Modified by Federico Crazzolara for dynamic endpoints.
 */

package de.nece.ccrl.tokenservice;

public class TokenServiceLocator extends org.apache.axis.client.Service implements de.nece.ccrl.tokenservice.TokenService {

    // Use to get a proxy class for NSL
    private java.lang.String NSL_address = null;


    // Use to get a proxy class for X509Exch
    private java.lang.String X509Exch_address = "http://localhost:8080/axis/services/X509Exch";
    

    public TokenServiceLocator(String endpoint){
	try{
	java.net.URL e = new java.net.URL(endpoint);
	if ((e.getPath()).equals("axis/services/X509Exch"))
	    X509Exch_address = endpoint;
	else NSL_address = endpoint;
	} catch (Exception e) {}
    }

    public java.lang.String getX509ExchAddress() {
        return X509Exch_address;
    }

    public java.lang.String getNSLAddress() {
        return NSL_address;
    }

    // The WSDD service name defaults to the port name.
    private java.lang.String NSLWSDDServiceName = "NSL";

    public java.lang.String getNSLWSDDServiceName() {
        return NSLWSDDServiceName;
    }

    public void setNSLWSDDServiceName(java.lang.String name) {
        NSLWSDDServiceName = name;
    }

    public de.nece.ccrl.tokenservice.SecurityTokenService getNSL() throws javax.xml.rpc.ServiceException {
       java.net.URL endpoint;
        try {
            endpoint = new java.net.URL(NSL_address);
        }
        catch (java.net.MalformedURLException e) {
            throw new javax.xml.rpc.ServiceException(e);
        }
        return getNSL(endpoint);
    }

    public de.nece.ccrl.tokenservice.SecurityTokenService getNSL(java.net.URL portAddress) throws javax.xml.rpc.ServiceException {
        try {
            de.nece.ccrl.tokenservice.NSLServiceSoapBindingStub _stub = new de.nece.ccrl.tokenservice.NSLServiceSoapBindingStub(portAddress, this);
            _stub.setPortName(getNSLWSDDServiceName());
            return _stub;
        }
        catch (org.apache.axis.AxisFault e) {
            return null;
        }
    }



   

    // The WSDD service name defaults to the port name.
    private java.lang.String X509ExchWSDDServiceName = "X509Exch";

    public java.lang.String getX509ExchWSDDServiceName() {
        return X509ExchWSDDServiceName;
    }

    public void setX509ExchWSDDServiceName(java.lang.String name) {
        X509ExchWSDDServiceName = name;
    }

    public de.nece.ccrl.tokenservice.SecurityTokenService getX509Exch() throws javax.xml.rpc.ServiceException {
       java.net.URL endpoint;
        try {
            endpoint = new java.net.URL(X509Exch_address);
        }
        catch (java.net.MalformedURLException e) {
            throw new javax.xml.rpc.ServiceException(e);
        }
        return getX509Exch(endpoint);
    }

    public de.nece.ccrl.tokenservice.SecurityTokenService getX509Exch(java.net.URL portAddress) throws javax.xml.rpc.ServiceException {
        try {
            de.nece.ccrl.tokenservice.X509ExchServiceSoapBindingStub _stub = new de.nece.ccrl.tokenservice.X509ExchServiceSoapBindingStub(portAddress, this);
            _stub.setPortName(getX509ExchWSDDServiceName());
            return _stub;
        }
        catch (org.apache.axis.AxisFault e) {
            return null;
        }
    }

    /**
     * For the given interface, get the stub implementation.
     * If this service has no port for the given interface,
     * then ServiceException is thrown.
     * This service has multiple ports for a given interface;
     * the proxy implementation returned may be indeterminate.
     */
    public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
        try {
            if (de.nece.ccrl.tokenservice.SecurityTokenService.class.isAssignableFrom(serviceEndpointInterface)) {
                de.nece.ccrl.tokenservice.NSLServiceSoapBindingStub _stub = new de.nece.ccrl.tokenservice.NSLServiceSoapBindingStub(new java.net.URL(NSL_address), this);
                _stub.setPortName(getNSLWSDDServiceName());
                return _stub;
            }
            if (de.nece.ccrl.tokenservice.SecurityTokenService.class.isAssignableFrom(serviceEndpointInterface)) {
                de.nece.ccrl.tokenservice.X509ExchServiceSoapBindingStub _stub = new de.nece.ccrl.tokenservice.X509ExchServiceSoapBindingStub(new java.net.URL(X509Exch_address), this);
                _stub.setPortName(getX509ExchWSDDServiceName());
                return _stub;
            }
        }
        catch (java.lang.Throwable t) {
            throw new javax.xml.rpc.ServiceException(t);
        }
        throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface:  " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName()));
    }

    /**
     * For the given interface, get the stub implementation.
     * If this service has no port for the given interface,
     * then ServiceException is thrown.
     */
    public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
        if (portName == null) {
            return getPort(serviceEndpointInterface);
        }
        String inputPortName = portName.getLocalPart();
        if ("NSL".equals(inputPortName)) {
            return getNSL();
        }
        else if ("X509Exch".equals(inputPortName)) {
            return getX509Exch();
        }
        else  {
            java.rmi.Remote _stub = getPort(serviceEndpointInterface);
            ((org.apache.axis.client.Stub) _stub).setPortName(portName);
            return _stub;
        }
    }

    public javax.xml.namespace.QName getServiceName() {
        return new javax.xml.namespace.QName("tokenservice.ccrl.nece.de", "TokenService");
    }

    private java.util.HashSet ports = null;

    public java.util.Iterator getPorts() {
        if (ports == null) {
            ports = new java.util.HashSet();
            ports.add(new javax.xml.namespace.QName("NSL"));
            ports.add(new javax.xml.namespace.QName("X509Exch"));
        }
        return ports.iterator();
    }

}
