Beispiel #1
0
        /*
        private void checkForErrorInDispositionReport(dispositionReport report, String Error, String entityKey)
        {

            if (entityKey != null && report != null && report.countainsErrorCode(DispositionReport.E_INVALID_KEY_PASSED))
            {
                log.info("entityKey " + entityKey + " was not found in the registry");
            }
            else
            {
                if (report == null)
                {
                    log.info("Missing DispositionReport");
                }
                else
                {
                    foreach (result result in report.result)
                    {
                  //      log.error(result.getErrInfo().getErrCode() + " " + result.getErrInfo().getValue());
                    }
                }
            }
        }
        */
        /**
         * Gets an auth token from the uddi server using the uddi auth token
         * <br>
         * Notice: never log auth tokens! Treat it like a password
         *
         * notes: changed to public to have access from the subscription
         * callback API 8/20/2013 AO
         *
         * @param endpointURL
         * @return
         * @throws TransportException
         * @throws DispositionReportFaultMessage
         * @throws RemoteException
         */
        public String getAuthToken(String endpointURL)
        {
            //if the token is older then 10 minutes discard it, and create a new one.
            if ((authToken != null && !"".Equals(authToken)) && (tokenBirthDate != null && DateTime.Now > tokenBirthDate.AddMilliseconds(600000)))
            {
                discard_authToken discardAuthToken = new discard_authToken();
                discardAuthToken.authInfo = (authToken);
                using (UDDI_Security_SoapBinding sec = getUDDINode().getTransport().getUDDISecurityService(endpointURL))
                {
                    getUDDINode().getTransport().getUDDISecurityService(endpointURL).discard_authToken(discardAuthToken);
                    authToken = null;
                }
            }
            if (authToken == null || "".Equals(authToken))
            {
                tokenBirthDate = new DateTime();
                get_authToken getAuthToken = new get_authToken();
                getAuthToken.userID = (getPublisher());
                if (isEncrypted)
                {
                    if (String.IsNullOrEmpty(cryptoProvider))
                    {
                        log.error("Credentials are encrypted but no cryptoProvider was defined in the config file!");
                    }
                    else
                        try
                        {
                            getAuthToken.cred = (CryptorFactory.getCryptor(this.cryptoProvider).decrypt(getPassword()));
                        }
                        catch (Exception ex)
                        {
                            log.error("Unable to decrypt credentials! sending it as is", ex);
                            getAuthToken.cred = (getPassword());
                        }
                }
                else
                {
                    getAuthToken.cred = (getPassword());
                }
                using (UDDI_Security_SoapBinding sec = getUDDINode().getTransport().getUDDISecurityService(endpointURL))
                {
                    authToken = getUDDINode().getTransport().getUDDISecurityService(endpointURL).get_authToken(getAuthToken).authInfo;
                }

            }
            return authToken;
        }
Beispiel #2
0
 /// <remarks/>
 public void get_authTokenAsync(get_authToken get_authToken1, object userState)
 {
     if ((this.get_authTokenOperationCompleted == null))
     {
         this.get_authTokenOperationCompleted = new System.Threading.SendOrPostCallback(this.Onget_authTokenOperationCompleted);
     }
     this.InvokeAsync("get_authToken", new object[] {
             get_authToken1}, this.get_authTokenOperationCompleted, userState);
 }
Beispiel #3
0
 /// <remarks/>
 public System.IAsyncResult Beginget_authToken(get_authToken get_authToken1, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("get_authToken", new object[] {
             get_authToken1}, callback, asyncState);
 }
Beispiel #4
0
 /// <remarks/>
 public void get_authTokenAsync(get_authToken get_authToken1)
 {
     this.get_authTokenAsync(get_authToken1, null);
 }
        internal static void Run(string[] args)
        {
            UDDIClient clerkManager = null;
            Transport transport = null;
            UDDIClerk clerk = null;
            try
            {
                clerkManager = new UDDIClient("uddi.xml");

                transport = clerkManager.getTransport("uddiv2");

                UDDI_Security_SoapBinding security = transport.getUDDISecurityService();
                UDDI_Inquiry_SoapBinding inquiry = transport.getUDDIInquiryService();
                UDDI_Publication_SoapBinding publish = transport.getUDDIPublishService();

                clerk = clerkManager.getClerk("uddiv2");

                save_business sb = new save_business();
                get_authToken rq=new get_authToken();
                rq.cred = "username";
                rq.userID="username";
                String token=security.get_authToken(rq).authInfo;
                System.Console.WriteLine("Got an auth token...");
                sb.authInfo = token;
                sb.businessEntity = new businessEntity[1];
                sb.businessEntity[0] = new businessEntity();
                sb.businessEntity[0].name = new name[] { new name("test business from .net via uddi2 translation", "en") };
                sb.businessEntity[0].description = new description[] { new description("a description", "en") };
                businessDetail detail=  publish.save_business(sb);
                System.Console.WriteLine("business saved");
                PrintUDDI<businessDetail> p = new PrintUDDI<businessDetail>();
                Console.Out.WriteLine(p.print(detail));

                save_service ss = new save_service();
                ss.authInfo = token;
                ss.businessService = new businessService[1];
                ss.businessService[0] = new businessService();
                ss.businessService[0].name = new name[] { new name("hello world", "en") };
                ss.businessService[0].businessKey = detail.businessEntity[0].businessKey;
                serviceDetail sd = publish.save_service(ss);
                System.Console.WriteLine("service saved");
                PrintUDDI<serviceDetail> p1 = new PrintUDDI<serviceDetail>();
                Console.Out.WriteLine(p1.print(sd));

                save_binding sbd = new save_binding();
                sbd.authInfo = token;
                sbd.bindingTemplate = new bindingTemplate[1];
                sbd.bindingTemplate[0] = new bindingTemplate();
                sbd.bindingTemplate[0].Item = new accessPoint("http://localhost", "endPoint");
                sbd.bindingTemplate[0].serviceKey = sd.businessService[0].serviceKey;
                bindingDetail bd = publish.save_binding(sbd);
                System.Console.WriteLine("binding saved");
                PrintUDDI<bindingDetail> p2 = new PrintUDDI<bindingDetail>();
                Console.Out.WriteLine(p2.print(bd));

                save_tModel stm = new save_tModel();
                stm.authInfo = token;
                stm.tModel = new tModel[1];
                stm.tModel[0] = new tModel();
                stm.tModel[0].name = new name("a uddiv2 tmodel", "en");
                tModelDetail td = publish.save_tModel(stm);
                System.Console.WriteLine("tModel saved");
                PrintUDDI<tModelDetail> p3 = new PrintUDDI<tModelDetail>();
                Console.Out.WriteLine(p3.print(td));

            }
            catch (Exception ex)
            {
                while (ex != null)
                {
                    System.Console.WriteLine("Error! " + ex.Message);
                    ex = ex.InnerException;
                }
            }
            finally
            {
                if (transport != null && transport is IDisposable)
                {
                    ((IDisposable)transport).Dispose();
                }
                if (clerk != null)
                    clerk.Dispose();
            }
        }