Exemple #1
0
        public Aligner(string config, string audioFile, string textFile, string recognizerName, string grammarName, string audioDataSourceName, bool optimize)
        {
            this.config                   = config;
            this.audioFile                = audioFile;
            this.textFile                 = textFile;
            this.PROP_RECOGNIZER          = recognizerName;
            this.PROP_GRAMMAR             = grammarName;
            this.PROP_AUDIO_DATA_SOURCE   = audioDataSourceName;
            this.optimizeP                = optimize;
            this.PROP_PERFORM_SPOTTING    = false;
            this.PROP_MODEL_BACKWARDJUMPS = false;
            this.PROP_MODEL_DELETIONS     = false;
            this.PROP_MODEL_REPETITIONS   = false;
            txtInTranscription            = readTranscription();
            phraseSpotterResult           = new List <PhraseSpotterResult>();

            // initializing the ConfigurationManager raises an error if com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl class is not loaded
            var s = new [email protected]();

            cm = new ConfigurationManager(config);
            absoluteBeamWidth       = cm.getGlobalProperty("absoluteBeamWidth");
            relativeBeamWidth       = cm.getGlobalProperty("relativeBeamWidth");
            addOutOfGrammarBranch   = cm.getGlobalProperty("addOOVBranch");
            outOfGrammarProbability = cm
                                      .getGlobalProperty("outOfGrammarProbability");
            phoneInsertionProbability = cm
                                        .getGlobalProperty("phoneInsertionProbability");
        }
        public static void Initialize(string ontologyProfilePath)
        {
            try
            {
                Manager = OWLManager.createOWLOntologyManager();
                //tento řádek je potřebný kvůli nedokonale převedené knihovně z javy, kvůli které se načítá owl parser
                [email protected] s = new [email protected]();


                // načtení owl souboru, který obsahuje metamodel a který každá vložená báze individuí importuje
                byte[] owlResourceUPMM = Properties.Resources.UPMM;
                java.io.ByteArrayInputStream upmmInputStream = new java.io.ByteArrayInputStream(owlResourceUPMM);
                OWLOntology ontologyUPMM = Manager.loadOntologyFromOntologyDocument(upmmInputStream);
                MetamodelIRI = ontologyUPMM.getOntologyID().getOntologyIRI();
                Trace.WriteLine("Loaded Metamodel Ontology : " + MetamodelIRI);

                // načtení owl báze konkrétního profilu
                java.io.File processModel     = new java.io.File(ontologyProfilePath);
                OWLOntology  knowledgeProfile = Manager.loadOntologyFromOntologyDocument(processModel);
                ProfileIRI = knowledgeProfile.getOntologyID().getOntologyIRI();
                Trace.WriteLine("Loaded Profile Ontology : " + ProfileIRI);


                // vytvoření reasoneru nad profilem
                Reasoner       = new StructuralReasonerFactory().createReasoner(knowledgeProfile, new SimpleConfiguration());
                PelletReasoner = new PelletReasonerFactory().createReasoner(knowledgeProfile, new SimpleConfiguration());
                //Reasoner = new Reasoner.ReasonerFactory().createReasoner(knowledgeProfile); HermiT
                Trace.WriteLine("Reasoner is running!");

                DataFactory = Manager.getOWLDataFactory();
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Ontology loading failed!", ex);
            }
        }
Exemple #3
0
        public bool SignXml(string RutaCertificado, string Clave, string RutaXML, string RutaFirmado, ref string mensaje)
        {
            //if (!ValidateAccessKey)
            //    return false;

            PrivateKey privateKey;
            Provider   provider;

            try
            {
                //X509Certificate certificate = LoadCertificate("","", out privateKey, out provider);

                X509Certificate certificate = null;
                provider   = null;
                privateKey = null;

                //Cargar certificado de fichero PFX
                KeyStore ks = KeyStore.getInstance("PKCS12");
                ks.load(new FileInputStream(RutaCertificado), Clave.ToCharArray());
                IPKStoreManager storeManager = new KSStore(ks, new PassStoreKS(Clave));
                List            certificates = storeManager.getSignCertificates();

                //Si encontramos el certificado...
                if (certificates.size() >= 1)
                {
                    certificate = (X509Certificate)certificates.get(0);

                    // Obtención de la clave privada asociada al certificado
                    privateKey = storeManager.getPrivateKey(certificate);

                    // Obtención del provider encargado de las labores criptográficas
                    provider = storeManager.getProvider(certificate);
                }

                if (certificate != null)
                {
                    TrustFactory.instance       = es.mityc.javasign.trust.TrustExtendFactory.newInstance();
                    TrustFactory.truster        = es.mityc.javasign.trust.MyPropsTruster.getInstance();
                    PoliciesManager.POLICY_SIGN = new es.mityc.javasign.xml.xades.policy.facturae.Facturae31Manager();

                    [email protected] s = new [email protected]();

                    PoliciesManager.POLICY_VALIDATION = new es.mityc.javasign.xml.xades.policy.facturae.Facturae31Manager();

                    DataToSign dataToSign = new DataToSign();
                    dataToSign.setXadesFormat(EnumFormatoFirma.XAdES_BES); //XAdES-EPES
                    dataToSign.setEsquema(XAdESSchemas.XAdES_132);
                    dataToSign.setPolicyKey("facturae31");
                    //dataToSign.setAddPolicy(true);
                    dataToSign.setAddPolicy(false);
                    dataToSign.setXMLEncoding("UTF-8");
                    dataToSign.setEnveloped(true);
                    dataToSign.addObject(new ObjectToSign(new InternObjectToSign("comprobante"), "contenido comprobante", null, "text/xml", null));

                    //string fileToSign = Path.Combine("", fileName);

                    Document doc = LoadXML(RutaXML);
                    dataToSign.setDocument(doc);

                    //dataToSign.setDocument(IDocumentoElectronicoExtensions.LoadXml(fileToSign));

                    Object[] res = new FirmaXML().signFile(certificate, dataToSign, privateKey, provider);

                    java.io.FileOutputStream file = new FileOutputStream(RutaFirmado);

                    UtilidadTratarNodo.saveDocumentToOutputStream((Document)res[0], file, true);
                    file.flush();
                    file.close();

                    //DeleteFile(fileToSign);
                }

                return(true);
            }
            catch (Exception ex)
            {
                //System.Windows.Forms.MessageBox.Show(ex.Message);
                Console.WriteLine(ex.Message);

                //System.Diagnostics.EventLog.WriteEntry("BcLog", "SignXml - Error en Certificado " + ex.Message);
                return(false);
            }
        }