コード例 #1
0
        static public GxLocation getlocation(IGxContext context,
                                             String sLocation)
        {
            GXXMLReader oReader;
            GxLocation  oLocation;

            if (context.nLocRead == 0)
            {
                oReader = new GXXMLReader(context.GetPhysicalPath());
                oReader.Open(context.GetPhysicalPath( ) + "location.xml");
                initLocations(context, oReader);
                if (oReader.ErrCode == 0)
                {
                    oReader.Close();
                }
            }
            context.nSOAPErr = 0;
            oLocation        = context.colLocations.GetItem(sLocation);
            context.nSOAPErr = 0;
            if (oLocation == null)
            {
                context.nSOAPErr = 1;
            }
            assigngroupproperties(context, oLocation);
            if (context.nSOAPErr != 0)
            {
                context.nSOAPErr                 = (short)(-20007);
                context.sSOAPErrMsg              = "Invalid location name.";
                oLocation                        = new GxLocation();
                oLocation.Name                   = sLocation;
                oLocation.Host                   = "";
                oLocation.Port                   = -1;
                oLocation.BaseUrl                = "";
                oLocation.Secure                 = -1;
                oLocation.ProxyServerHost        = "";
                oLocation.ProxyServerPort        = -1;
                oLocation.Timeout                = -1;
                oLocation.CancelOnError          = 0;
                oLocation.Authentication         = 0;
                oLocation.AuthenticationMethod   = 0;
                oLocation.AuthenticationRealm    = "";
                oLocation.AuthenticationUser     = "";
                oLocation.AuthenticationPassword = "";
                oLocation.GroupLocation          = "";
                context.colLocations.Add(oLocation, sLocation);
            }
            else
            {
                context.nSOAPErr    = 0;
                context.sSOAPErrMsg = "";
            }
            return(oLocation);
        }
コード例 #2
0
 public override void initialize( )
 {
     GXSoapHTTPClient = new GxHttpClient(context);
     sReturn          = "";
     GXSoapXMLReader  = new GXXMLReader(context.GetPhysicalPath());
     GXSoapXMLWriter  = new GXXMLWriter(context.GetPhysicalPath());
     currSoapErrmsg   = "";
     sTagName         = "";
     sFaultCode       = "";
     sFaultString     = "";
     sDetail          = "";
     oLocation        = new GxLocation();
     /* GeneXus formulas. */
     context.Gx_err = 0;
 }
コード例 #3
0
 public void initialize( )
 {
     defaultExecute     = "";
     GXSoapHTTPClient   = new GxHttpClient(context);
     execName           = "";
     targetResourceName = "";
     GXSoapXMLReader    = new GXXMLReader(context.GetPhysicalPath());
     GXSoapXMLWriter    = new GXXMLWriter(context.GetPhysicalPath());
     currSoapErrmsg     = "";
     sTagName           = "";
     oLocation          = new GxLocation();
     sFaultCode         = "";
     sFaultString       = "";
     sDetail            = "";
     return;
 }
コード例 #4
0
        static public void assigngroupproperties(IGxContext context,
                                                 GxLocation oLocation)
        {
            String     sLocation;
            GxLocation oGroupLocation;
            int        nOldSOAPErr;

            if (oLocation != null)
            {
                sLocation = oLocation.GroupLocation;
                if (StringUtil.StrCmp(sLocation, "") != 0)
                {
                    nOldSOAPErr      = context.nSOAPErr;
                    oGroupLocation   = context.colLocations.GetItem(sLocation);
                    context.nSOAPErr = 0;
                    if (oGroupLocation == null)
                    {
                        context.nSOAPErr = 1;
                    }
                    if (context.nSOAPErr == 0)
                    {
                        oLocation.Host                        = oGroupLocation.Host;
                        oLocation.Port                        = oGroupLocation.Port;
                        oLocation.BaseUrl                     = oGroupLocation.BaseUrl;
                        oLocation.Secure                      = oGroupLocation.Secure;
                        oLocation.ProxyServerHost             = oGroupLocation.ProxyServerHost;
                        oLocation.ProxyServerPort             = oGroupLocation.ProxyServerPort;
                        oLocation.Timeout                     = oGroupLocation.Timeout;
                        oLocation.CancelOnError               = oGroupLocation.CancelOnError;
                        oLocation.Authentication              = oGroupLocation.Authentication;
                        oLocation.AuthenticationMethod        = oGroupLocation.AuthenticationMethod;
                        oLocation.AuthenticationRealm         = oGroupLocation.AuthenticationRealm;
                        oLocation.AuthenticationUser          = oGroupLocation.AuthenticationUser;
                        oLocation.AuthenticationPassword      = oGroupLocation.AuthenticationPassword;
                        oLocation.ProxyAuthentication         = oGroupLocation.ProxyAuthentication;
                        oLocation.ProxyAuthenticationMethod   = oGroupLocation.ProxyAuthenticationMethod;
                        oLocation.ProxyAuthenticationRealm    = oGroupLocation.ProxyAuthenticationRealm;
                        oLocation.ProxyAuthenticationUser     = oGroupLocation.ProxyAuthenticationUser;
                        oLocation.ProxyAuthenticationPassword = oGroupLocation.ProxyAuthenticationPassword;
                    }
                    context.nSOAPErr = (short)(nOldSOAPErr);
                }
            }
        }
コード例 #5
0
    public void Setup(string eoName, GxLocation loc, object serviceClient)
    {
        String Parameters = loc.Configuration.ToString();

        string[] Parameter = Parameters.Split(';');
        String   IdentStr  = Parameter[1];
        String   DGICert   = Parameter[2];

        //String ClientCert = Parameter[3];
        Byte[] bytes          = System.Convert.FromBase64String(Parameter[3]);
        String Clientpassword = Parameter[4];
        String ServUri        = Parameter[5];


        if (eoName == "WS_eFactura")   // Este es el nombre dele external object para filtrar
        {
            // Aca se implementa la configuracion del serviceClient segun corresponda, por ejemplo:
            ClientBase <ISdtWS_eFactura> svc = serviceClient as ClientBase <ISdtWS_eFactura>;

            //Seteo el protection level por programa
            svc.Endpoint.Contract.ProtectionLevel = System.Net.Security.ProtectionLevel.Sign;

            //Declaro el objeto donde voy a guardar el Certificado desde el path del archivo // array de bytes
            System.Security.Cryptography.X509Certificates.X509Certificate2 crtCLI;
            System.Security.Cryptography.X509Certificates.X509Certificate2 crtDGI;

            // crtCLI = new System.Security.Cryptography.X509Certificates.X509Certificate2(ClientCert.Trim(), Clientpassword.Trim());

            //crtCLI = new System.Security.Cryptography.X509Certificates.X509Certificate2(ClientCert.Trim());
            crtCLI = new System.Security.Cryptography.X509Certificates.X509Certificate2(bytes);
            crtDGI = new System.Security.Cryptography.X509Certificates.X509Certificate2(DGICert.Trim());

            //Seteo al WS los certificados
            svc.ClientCredentials.ClientCertificate.Certificate         = crtCLI;
            svc.ClientCredentials.ServiceCertificate.DefaultCertificate = crtDGI;
            svc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;


            //Creo la direccion del WS, que tiene la URI y el DNS(es el CN del certificado de la DGI)
            svc.Endpoint.Address = new System.ServiceModel.EndpointAddress(new Uri(ServUri.Trim()),
                                                                           EndpointIdentity.CreateDnsIdentity(IdentStr.Trim()));
        }
    }
コード例 #6
0
        static public String read_section(IGxContext context,
                                          GXXMLReader oReader,
                                          GxLocation oLocation)
        {
            String sSection;

            sSection = "";
            if (oReader.NodeType == 1)
            {
                sSection = oReader.Name;
                oReader.Read();
                while (!((StringUtil.StrCmp(oReader.Name, sSection) == 0) && (oReader.NodeType == 2)))
                {
                    if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "host") == 0)
                    {
                        oLocation.Host = oReader.Value;
                    }
                    else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "port") == 0)
                    {
                        oLocation.Port = (int)(NumberUtil.Val(oReader.Value, "."));
                    }
                    else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "baseurl") == 0)
                    {
                        oLocation.BaseUrl = oReader.Value;
                    }
                    else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "resourcename") == 0)
                    {
                        oLocation.ResourceName = oReader.Value;
                    }
                    else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "secure") == 0)
                    {
                        oLocation.Secure = (short)(NumberUtil.Val(oReader.Value, "."));
                    }
                    else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "proxyserverhost") == 0)
                    {
                        oLocation.ProxyServerHost = oReader.Value;
                    }
                    else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "proxyserverport") == 0)
                    {
                        oLocation.ProxyServerPort = (int)(NumberUtil.Val(oReader.Value, "."));
                    }
                    else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "timeout") == 0)
                    {
                        oLocation.Timeout = (short)(NumberUtil.Val(oReader.Value, "."));
                    }
                    else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "cancelonerror") == 0)
                    {
                        oLocation.CancelOnError = (short)(NumberUtil.Val(oReader.Value, "."));
                    }
                    else if (StringUtil.StrCmp(oReader.Name, "Authentication") == 0)
                    {
                        oLocation.Authentication       = 1;
                        oLocation.AuthenticationMethod = (short)(NumberUtil.Val(StringUtil.Str((decimal)(0), 1, 0), "."));
                        oReader.Read();
                        while (!((StringUtil.StrCmp(oReader.Name, "Authentication") == 0) && (oReader.NodeType == 2)))
                        {
                            if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "authenticationmethod") == 0)
                            {
                                oLocation.AuthenticationMethod = (short)(NumberUtil.Val(oReader.Value, "."));
                            }
                            else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "authenticationuser") == 0)
                            {
                                oLocation.AuthenticationUser = oReader.Value;
                            }
                            else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "authenticationrealm") == 0)
                            {
                                oLocation.AuthenticationRealm = oReader.Value;
                            }
                            else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "authenticationpassword") == 0)
                            {
                                oLocation.AuthenticationPassword = oReader.Value;
                            }
                            oReader.Read();
                        }
                    }
                    else if (StringUtil.StrCmp(oReader.Name, "Proxyauthentication") == 0)
                    {
                        oLocation.ProxyAuthenticationMethod = (short)(NumberUtil.Val(StringUtil.Str((decimal)(0), 1, 0), "."));
                        oReader.Read();
                        while (!((StringUtil.StrCmp(oReader.Name, "Proxyauthentication") == 0) && (oReader.NodeType == 2)))
                        {
                            if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "proxyauthenticationmethod") == 0)
                            {
                                oLocation.ProxyAuthenticationMethod = (short)(NumberUtil.Val(oReader.Value, "."));
                            }
                            else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "proxyauthenticationuser") == 0)
                            {
                                oLocation.ProxyAuthenticationUser = oReader.Value;
                            }
                            else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "proxyauthenticationrealm") == 0)
                            {
                                oLocation.ProxyAuthenticationRealm = oReader.Value;
                            }
                            else if (StringUtil.StrCmp(StringUtil.Lower(oReader.Name), "proxyauthenticationpassword") == 0)
                            {
                                oLocation.ProxyAuthenticationPassword = oReader.Value;
                            }
                            oReader.Read();
                        }
                    }
                    oReader.Read();
                }
            }
            return(sSection);
        }
コード例 #7
0
        static public void initLocations(IGxContext context,
                                         GXXMLReader oReader)
        {
            String     sSection;
            String     sName;
            short      nFirstRead;
            GxLocation oLocation;

            context.nLocRead     = 1;
            context.colLocations = new GxLocationCollection();
            if (oReader.ErrCode == 0)
            {
                if (oReader.ReadType(1, "GXLocations") > 0)
                {
                    oReader.Read();
                    while (!((StringUtil.StrCmp(oReader.Name, "GXLocations") == 0) && (oReader.NodeType == 2)))
                    {
                        if ((StringUtil.StrCmp(oReader.Name, "GXLocation") == 0) && (oReader.NodeType == 1))
                        {
                            sName            = oReader.GetAttributeByName("name");
                            oLocation        = context.colLocations.GetItem(sName);
                            context.nSOAPErr = 0;
                            if (oLocation == null)
                            {
                                context.nSOAPErr = 1;
                            }
                            if (context.nSOAPErr != 0)
                            {
                                /* Error while reading XML. Code:  4 . Message:  Input error . */
                                oLocation                        = new GxLocation();
                                oLocation.Name                   = sName;
                                oLocation.Host                   = "localhost";
                                oLocation.Port                   = 80;
                                oLocation.BaseUrl                = "/";
                                oLocation.Secure                 = 0;
                                oLocation.ProxyServerHost        = "";
                                oLocation.ProxyServerPort        = 0;
                                oLocation.Timeout                = 0;
                                oLocation.CancelOnError          = 0;
                                oLocation.Authentication         = 0;
                                oLocation.AuthenticationMethod   = 0;
                                oLocation.AuthenticationRealm    = "";
                                oLocation.AuthenticationUser     = "";
                                oLocation.AuthenticationPassword = "";
                                oLocation.GroupLocation          = "";
                                context.colLocations.Add(oLocation, sName);
                            }
                            oLocation.GroupLocation = "";
                            nFirstRead = 1;
                            oReader.Read();
                            while (!((StringUtil.StrCmp(oReader.Name, "GXLocation") == 0) && (oReader.NodeType == 2)))
                            {
                                sSection = read_section(context, oReader, oLocation);
                                if (((StringUtil.StrCmp(sSection, "Common") == 0) && (nFirstRead == 1)) || (StringUtil.StrCmp(sSection, "HTTP") == 0))
                                {
                                    nFirstRead = 0;
                                }
                                oReader.Read();
                            }
                        }
                        oReader.Read();
                    }
                }
            }
        }