Author: victorjabur

Software de Tradução de Idiomas no Linux – GoldenDict Babylon

Olá,

Se você está procurando algum software parecido com o Babylon do Windows e, assim como eu, utiliza o Linux Ubuntu ou qualquer outra distro. Você achou, o nome dele é: GoldenDict.

É possível instalá-lo a partir do “Ubuntu Software Center” ou sudo apt-get install goldendict

Existem inúmeros dicionários gratuitos fornecidos pela própria Babylon, aqui:

http://www.babylon.com/free-dictionaries/

Todos os dicionários babylon possuem a extensão .BGL

O que atualmente está complicando usuários Linux de baixar estes dicionários, é que a Babylon está oferecendo arquivos executáveis (.exe) que baixam o dicionário assim que o executável roda. Para facilitar, estou disponibilizando três principais dicionários aqui:

Se você precisar de outros dicionários, baixe o executável do Windows no site acima (free dictionaries). O Windows irá baixar o arquivo com a extensão .BGL para a pasta C:\Users\seuusuario\AppData\Local\Babylon

Espero ter ajudado !

Até a próxima.
Victor Jabur

Advertisements

Compiling MySQLdb 1.2.3 on Windows 32 and 64 – Without need the MySQL Database 5.5 installed

Hi,

If you wish the module already compiled, access here: http://blog.victorjabur.com/2011/06/08/modules-python-library-compiled-for-windows-32-and-64-unofficial-windows-binaries-for-python/

First Thing: Follow this main steps to prepare the pre-requirements for compile this module:

http://blog.victorjabur.com/2011/06/05/compiling-python-2-7-modules-on-windows-32-and-64-using-msvc-2008-express/

1 – Compiling MySQLdb 1.2.3 for Mysql 5.5 database

1.1 – You will need to download the latest version of MySQL Connector C here: http://dev.mysql.com/downloads/connector/c/

* Important: Make the download properly for your platform (32 or 64 bits).

1.2 – Make the download of MySQLdb plugin here and extract to any folder: http://sourceforge.net/projects/mysql-python/

1.3 – Edit this file (MySQL-python-1.2.3/setup_windows.py) inside of folder extracted:

At Line 7 of the file, comment the two follow lines and add another, like this:

    #serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
    #mysql_root, dummy = _winreg.QueryValueEx(serverKey,'Location')
    mysql_root = ''

At Line 19, put the path to your Connector C installed:

    library_dirs = [ os.path.join(mysql_root, r'lib\opt'), 'C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt' ]
    libraries = [ 'kernel32', 'advapi32', 'wsock32', client ]
    include_dirs = [ os.path.join(mysql_root, r'include'), 'C:\Program Files\MySQL\MySQL Connector C 6.0.2\include' ]
    extra_compile_args = [ '/Zl' ]

Important: Specify the correct path for your platform (32 or 64 bits). Above the platform is 64 bits, to 32 bits use this path: “C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2”.

1.4 – Make the build:

python setup.py build --compiler msvc
python setup.py bdist_wininst

It’s finish.

The advantage os this technique an a comparison with others posts is:

1 – The MySQL Database is not required on machine (only the connector c)
2 – Not is necessary make the update on the windows registry:

# The Windows registry key for MySQL.
# This has to be set for Windows builds to work.
# Only change this if you have a different version.
registry_key = SOFTWARE\MySQL AB\MySQL Server 5.0

Credits and References to this post:

http://chaos.weblogs.us/archives/327
http://www.fuyun.org/2009/12/install-mysql-for-python-on-windows/

Bye,
Victor Jabur

Modules Python Library Compiled for Windows 32 and 64 – Unofficial Windows Binaries for Python

Unofficial Windows Binaries for Python Extension Packages

This is a list of python modules compiled for me, the intention is to create a complete list of windows modules for python, this post is always updated to extend this list. I will need your help with suggestions about wich modules will be available here and links about already existents modules on the web. The files are provided “as is” without warranty or support of any kind. The entire risk as to the quality and performance is with you. The files are unofficial (meaning: informal, unrecognized, personal, unsupported) and made available for testing and evaluation purposes only.

Do you need another module that isn’t available at this list ? Send an e-mail and request your module.
victorjabur@gmail.com

Links with more plugins on Web:

http://www.lfd.uci.edu/~gohlke/pythonlibs/

—————————————————————————————————————–
Django – Framework Webhttps://www.djangoproject.com/
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.

Django-1.3.1.win32-py2.7.exe [6.4 Mb] [Python 2.7] [32 bit] [JUN 08, 2011]
Django-1.3.1.win-amd64-py2.7.exe [6.5 Mb] [Python 2.7] [64 bit] [JUN 08, 2011]

—————————————————————————————————————–
mpi4py – Plugin MPI for Pythonhttp://mpi4py.scipy.org/http://en.wikipedia.org/wiki/Message_Passing_Interface
Message Passing Interface (MPI) is an API specification that allows processes to communicate with one another by sending and receiving messages. Besides many other applications, it is a de facto standard for parallel programs running on computer clusters and supercomputers, where the cost of accessing non-local memory is high. MPI was created since 1992 by William Gropp, Ewing Lusk and others, a first standard appeared in 1994.

mpi4py-1.2.2.win32-py2.7.exe [445 Kb] [Python 2.7] [32 bit] [JUN 08, 2011]
mpi4py-1.2.2.win-amd64-py2.7.exe [522 Kb] [Python 2.7] [64 bit] [JUN 08, 2011]

—————————————————————————————————————–
MySQLdb – Plugin Connector of Database MySQL to Pythonhttp://sourceforge.net/projects/mysql-python/
Message Passing Interface (MPI) is an API specification that allows processes to communicate with one another by sending and receiving messages. Besides many other applications, it is a de facto standard for parallel programs running on computer clusters and supercomputers, where the cost of accessing non-local memory is high. MPI was created since 1992 by William Gropp, Ewing Lusk and others, a first standard appeared in 1994.

MySQL-python-1.2.3.win32-py2.7.exe [1 Mb] [Python 2.7] [32 bit] [JUN 08, 2011]
MySQL-python-1.2.3.win-amd64-py2.7.exe [1.1 Mb] [Python 2.7] [64 bit] [JUN 08, 2011]

—————————————————————————————————————–
Paramiko – SSH2 for Pythonhttp://www.lag.net/paramiko/
Paramiko is a module for python 2.2 (or higher) that implements the SSH2 protocol for secure (encrypted and authenticated) connections to remote machines. unlike SSL (aka TLS), SSH2 protocol does not require heirarchical certificates signed by a powerful central authority. you may know SSH2 as the protocol that replaced telnet and rsh for secure access to remote shells, but the protocol also includes the ability to open arbitrary channels to remote services across the encrypted tunnel — this is how sftp works, for example. It is written entirely in python (no C or platform-dependent code) and is released under the GNU LGPL (lesser GPL).

paramiko-1.7.7.1.win32-py2.7.exe [331 Kb] [Python 2.7] [32 bit] [JUN 08, 2011]
paramiko-1.7.7.1.win-amd64-py2.7.exe [356 Kb] [Python 2.7] [64 bit] [JUN 08, 2011]

—————————————————————————————————————–
PyAMF – AMF for Pythonhttp://www.pyamf.org
PyAMF provides Action Message Format (AMF) support for Python that is compatible with the Adobe Flash Player. It includes integration with Python web frameworks like Django, Pylons, Twisted, SQLAlchemy, web2py and more.

PyAMF-0.6.1.win32-py2.7.exe [508 Kb] [Python 2.7] [32 bit] [JUN 08, 2011]
PyAMF-0.6.1.win-amd64-py2.7.exe [551 Kb] [Python 2.7] [64 bit] [JUN 08, 2011]

—————————————————————————————————————–
PyCrypto – Python Cryptography Toolkithttps://www.dlitz.net/software/pycrypto/http://sourceforge.net/projects/pycrypto/http://www.amk.ca/python/code/crypto.html
This is a collection of cryptographic algorithms and protocols, implemented for use from Python.

pycrypto-2.3.win32-py2.7.exe [545 Kb] [Python 2.7] [32 bit] [JUN 08, 2011]
pycrypto-2.3.win-amd64-py2.7.exe [572 Kb] [Python 2.7] [64 bit] [JUN 08, 2011]

—————————————————————————————————————–
PyXMLSec – PyXMLSec is a set of Python bindings for the XML Security Library.http://pyxmlsec.labs.libre-entreprise.org/

pyxmlsec-0.3.0.win32-py2.7.exe [255 Kb] [Python 2.7] [32 bit] [SET 29, 2012]
libxml2-python-2.7.7.win32-py2.7.exe (Pre-Requisite) [1.5Mb] [Python 2.7] [32 bit] [SET 29, 2012]
dll_pyxmlsec_0.3.0_py2.7.rar (Pre-Requisite Dlls - Put this on your C:\Python27) [998Kb] [Python 2.7] [32 bit] [SET 29, 2012]

—————————————————————————————————————–
PyBluez- PyBluez is an effort to create python wrappers around system Bluetooth resources to allow Python developers to easily and quickly create Bluetooth applications.http://code.google.com/p/pybluez/

PyBluez-0.18.win32-py2.7.exe [286 Kb] [Python 2.7] [32 bit] [SET 29, 2012]

—————————————————————————————————————–
DbfPy – DbfPy is a python-only module for reading and writing DBF-files. It was created by Jeff Kunce and then modified by Hans Fiby.http://dbfpy.sourceforge.net/

dbfpy-2.2.5_python_27_.win32.exe [211 Kb] [Python 2.7] [32 bit] [MAY 28, 2013]
dbfpy-2.2.5.win-python_27_amd64.exe [238 Kb] [Python 2.7] [64 bit] [MAY 28, 2013]

—————————————————————————————————————–
PyXML – PyXml is a python module to work with the Xml format. It was created on 2000 year. PyXML is no longer maintained.http://sourceforge.net/projects/pyxml/

PyXML-0.8.4.win32-py2.7.exe [1 Mb] [Python 2.7] [32 bit] [AUG 19, 2014]
PyXML-0.8.4.win-amd64-py2.7.exe [1 Mb] [Python 2.7] [64 bit] [AUG 19, 2014]

—————————————————————————————————————–

Do you need another module that isn’t available at this list ? Send an e-mail and request your module.
victorjabur@gmail.com

Compiling Python 2.7 Modules on Windows 32 and 64 using MSVC++ 2008 Express

Hello,

On this post i will explain how to build, compile, install and distribute python modules on Windows using Microsoft Visual C++ Express Edition.
This post will be constantly updated to cover future updates of python, windows and msvc++ versions.

For this example i will use the PyCrypto – http://pycrypto.org because this is an example that don’t have packages for windows x64 on the web.

Observation: Don’t use Microsoft Visual C++ Express Edition 2010 to build python modules, because this will not work due to Python 2.7 was built using the 2008 version. This is an error that occurs when you try to build PyCrypto and Paramiko using the 2010 version and execute the import module:

>>> import paramiko
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\paramiko\__init__.py", line 69, in <module>
    from transport import SecurityOptions, Transport
  File "C:\Python27\lib\site-packages\paramiko\transport.py", line 32, in <module>
    from paramiko import util
  File "C:\Python27\lib\site-packages\paramiko\util.py", line 32, in <module>
    from paramiko.common import *
  File "C:\Python27\lib\site-packages\paramiko\common.py", line 98, in <module>
    from Crypto import Random
  File "C:\Python27\lib\site-packages\Crypto\Random\__init__.py", line 28, in <module>
    import OSRNG
  File "C:\Python27\lib\site-packages\Crypto\Random\OSRNG\__init__.py", line 34, in <module>
    from Crypto.Random.OSRNG.nt import new
  File "C:\Python27\lib\site-packages\Crypto\Random\OSRNG\nt.py", line 28, in <module>
    import winrandom
ImportError: DLL load failed: The specified module could not be found.

1 – Building and Installing PyCrypto Module for Windows 7 64 bits:

1.1 – You must have installed the Python 64 bits version: http://www.python.org/ftp/python/2.7.1/python-2.7.1.amd64.msi

1.2 – You should install the C Compiler for Windows – Microsoft Visual C++ Express Edition 2008: available here:http://www.microsoft.com/express/Downloads/#Visual_Studio_2008_Express_Downloads

ISO File to Download: http://www.microsoft.com/express/Downloads/#2008-All

1.3 – You should install the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1: available here: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505

ISO File To Download (64 bits): http://download.microsoft.com/download/2/E/9/2E911956-F90F-4BFB-8231-E292A7B6F287/GRMSDKX_EN_DVD.iso

This is required because the Express Edition 2008 C++ don’t contains the 64 bits compiler. This is required only for Windows 7 64 bits version.

Important: Don’t use the “Microsoft Windows SDK for Windows 7 and .NET Framework 4” because it’s not compatible with msvc++ express 2008 edition.

1.4 – Install the Python Setup Tools available here: http://pypi.python.org/pypi/setuptools#downloads

1.5 – Include in your Advanced Variables Environment the binaries of Python. Right click at “My Computer” icon -> Properties -> Advanced Environment and edit your Path Variable including this two directories there:
Path = C:\Python27\Scripts;C:\Python27; + Path

1) C:\Python27\Scripts
2) C:\Python27

1.6 – Copy this file:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat

To this follow folder and rename the file (vcvars64.bat to vcvarsamd64.bat):

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat

1.7 – Edit the file msvc9compiler.py inside of directory C:\Python27\Lib\distutils\msvc9compiler.py

After the line 651 approximately, find this line: – ld_args.append(‘/MANIFESTFILE:’ + temp_manifest)
Add the following line after the above line:

ld_args.append('/MANIFEST')

1.8 – Edit the file msvccompiler.py inside of directory C:\Python27\Lib\distutils\msvccompiler.py

At line 153 approximately, insert this line: return 9.0, as following, in this piece of code:

def get_build_version():
    """Return the version of MSVC that was used to build Python.

    For Python 2.3 and up, the version number is included in
    sys.version.  For earlier versions, assume the compiler is MSVC 6.
    """
    return 9.0
    prefix = "MSC v."
    i = string.find(sys.version, prefix)
    if i == -1:
        return 6

1.9 – Certify that exists the follow environment variable in your system, if don’t exist create a new one:

Name: VS90COMNTOOLS
Value: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\

1.10 – Extract the file pycrypto-2.3.tar.gz that you downloaded before, open a dos command and access the pycrypto-2.3 folder

1.11 – Execute this command to compile, build and install the module:

python setup.py build --compiler msvc
python setup.py install

1.12 – Test if the package was generated successfully executing an import Crypto at Python shell.

1.13 – It’s finish. Optionally, you can distribute your compiled modules as an windows executable (.exe) file, executing this simple command on folder of your module, this case is pycrypto-2.3:

python setup.py bdist_wininst

As a result you will get a executable file with graphical interface created inside of folder “dist” and other people can install this executable file without to prepare a complex environment for build your own module. This is my result file of this process. http://arquivos.victorjabur.com/python/modules/pycrypto-2.3.win-amd64-py2.7.exe

2 – Building and Installing PyCrypto Module for Windows All Versions 32 bits:

2.1 – You must have installed the Python 32 bits version: http://www.python.org/ftp/python/2.7.1/python-2.7.1.msi

2.2 – You should install the C Compiler for Windows – Microsoft Visual C++ Express Edition 2008: available here:http://www.microsoft.com/express/Downloads/#Visual_Studio_2008_Express_Downloads

ISO File to Download: http://www.microsoft.com/express/Downloads/#2008-All

2.3 – Install the Python Setup Tools available here: http://pypi.python.org/pypi/setuptools#downloads

2.4 – Include in your Advanced Variables Environment the binaries of Python. Right click at “My Computer” icon -> Properties -> Advanced Environment and edit your Path Variable including this two directories there:
Path = C:\Python27\Scripts;C:\Python27; + Path

1) C:\Python27\Scripts
2) C:\Python27

2.5 – Edit the file msvc9compiler.py inside of directory C:\Python27\Lib\distutils\msvc9compiler.py

After the line 651 approximately, find this line: – ld_args.append(‘/MANIFESTFILE:’ + temp_manifest)
Add the following line after the above line:

ld_args.append('/MANIFEST')

2.6 – Edit the file msvccompiler.py inside of directory C:\Python27\Lib\distutils\msvccompiler.py

At line 153 approximately, insert this line: return 9.0, as following, in this piece of code:

def get_build_version():
    """Return the version of MSVC that was used to build Python.

    For Python 2.3 and up, the version number is included in
    sys.version.  For earlier versions, assume the compiler is MSVC 6.
    """
    return 9.0
    prefix = "MSC v."
    i = string.find(sys.version, prefix)
    if i == -1:
        return 6

2.7 – Certify that exists the follow environment variable in your system, if don’t exist create a new one:

Name: VS90COMNTOOLS
Value: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\

2.8 – Extract the file pycrypto-2.3.tar.gz that you downloaded before, open a dos command and access the pycrypto-2.3 folder

2.9 – Execute this command to compile, build and install the module:

python setup.py build --compiler msvc
python setup.py install

2.10 – Test if the package was generated successfully executing an import Crypto at Python shell.

2.11 – It’s finish. Optionally, you can distribute your compiled modules as an windows executable (.exe) file, executing this simple command on folder of your module, this case is pycrypto-2.3:

python setup.py bdist_wininst

As a result you will get a executable file with graphical interface created inside of folder “dist” and other people can install this executable file without to prepare a complex environment for build your own module. This is my result file of this process. http://arquivos.victorjabur.com/python/modules/pycrypto-2.3.win32-py2.7.exe

Credits and References to this post:

http://nukeit.org/compile-python-2-7-packages-with-visual-studio-2010-express/
http://yorickdowne.wordpress.com/2010/12/22/compiling-pycrypto-on-win7-64/
http://www.lfd.uci.edu/~gohlke/pythonlibs/
http://www.fuyun.org/2009/12/install-mysql-for-python-on-windows/
http://mattptr.net/2010/07/28/building-python-extensions-in-a-modern-windows-environment/

Good Bye.
Victor Jabur

Utilitário para geração de TrustStore (JKS) – Java

Olá Pessoal,

Desenvolvi um utilitário que transforma um arquivo zip, contendo “n” certificados de Autoridades Certificadoras para um arquivo JKS.

Para referência segue um link que contém todas as CA’s brasileiras:

http://acraiz.icpbrasil.gov.br/credenciadas/CertificadosAC-ICP-Brasil/ACcompactado.zip

Como seria o processo normal ?

1 – Java Keytool – http://download.oracle.com/javase/6/docs/technotes/tools/windows/keytool.html
É um software que acompanha a máquina virtual Java (jdk), utilizado para diversas finalidades com relação à segurança de aplicações e pode ser usado para gerar o pacote JKS.
Seguem dois comandos exemplo para se trabalhar com arquivos JKS de truststore:

1. Listando todos os certificados contidos em um arquivo JKS:

keytool –list –v –keystore C:\meukeystore.jks

2. Importando um certificado de uma AC para dentro de um JKS pré-existente

keytool –import –trustcacerts –file C:\certificadoAC.cer –alias apelidoentrada –keystore C:\meutruststore.jks

Observação: Caso não exista um jks no diretório especificado em -keystore, será criado um automaticamente.
O arquivo ACcompactado.zip especificado na URL anteriormente, possui atualmente 84 certificados, portanto, deve-se executar o comando (2), 84 vezes, alterando o -alias e o –file. Por ser esta uma forma muito trabalhosa de se gerar um arquivo Trusted JKS, foi criado um utilitário que auxiliará nesta etapa, apresentado no próximo capítulo.

2 – Usando o utilitário – utilitarioTrustJKS.jar
O utilitário desenvolvido basicamente recebe como entrada um arquivo zip com todos os certificados desejados e gera um arquivo trust.jks.
Parâmetros de Entrada:
1 – caminhoZip – Diretório do arquivo zip que contém todos os certificados das AC’s
2 – caminhoSaida – Diretório de saída, onde será gerado o truststore.jks
3 – senhaKestore – Senha do arquivo TrustStore JKS
4 – incluirExpirados (opcional) – valor default => false) – Possui os valores true ou false. Informa se certificados expirados ou não válidos ainda deverão ser incluídos no arquivo JKS gerado.

Exemplo de utilização:

java -jar utilitarioTrustJKS.jar C:\ACcompactado.zip C:\truststore.jks 123456789 true

Link para Download do arquivo Jar:
http://arquivos.victorjabur.com/java/seguranca/utilitarioTrustJKS.jar

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.KeyStore;
import java.security.cert.CertificateExpiredException;
import java.security.cert.CertificateFactory;
import java.security.cert.CertificateNotYetValidException;
import java.security.cert.X509Certificate;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import com.sun.xml.internal.messaging.saaj.util.ByteInputStream;

public class Main {

	private String caminhoZIP = "C:\\ACcompactado.zip";
	private String caminhoSaida = "C:\\truststore.jks";
	private String senhaKeystore = "123456789";
	private Boolean incluirExpirados = false;

	public static void main(String[] args) throws Exception {
		Main main = new Main();
		main.validarParametrosEntrada(args);
		List<X509Certificate> listaCertificadosValidos = main.getListaCertificadosValidos();
		main.gerarJKS(listaCertificadosValidos);
		System.out.println("Arquivo JKS gerado com sucesso - " + listaCertificadosValidos.size() + " certificados incluidos");
	}

	public void validarParametrosEntrada(String[] args){
		if(args.length < 3){
			throw new RuntimeException("O numero minimo de parametros = 3. caminhoZip caminhoSaida senhaKeystore e incluirExpirados (Opcional) ");
		}else{
			String caminhoZip = args[0];
			validacaoLeituraArquivo(new File(caminhoZip));
			this.caminhoZIP = caminhoZip;
			String caminhoSaida = args[1];
			this.caminhoSaida = caminhoSaida;
			String senhaKeystore = args[2];
			this.senhaKeystore = senhaKeystore;
			if(args.length >= 4){
				String incluirExpirados = args[3];
				if(incluirExpirados.equals("true") || incluirExpirados.equals("false")){
					this.incluirExpirados = Boolean.valueOf(incluirExpirados);
				}else{
					throw new RuntimeException("O parametro incluirExpirados (4) deve ser true ou false");
				}
			}
		}
	}
	
	public List<X509Certificate> getListaCertificadosValidos() {
		File arquivoZipEntrada = new File(this.caminhoZIP);
		validacaoLeituraArquivo(arquivoZipEntrada);
		List<X509Certificate> x509CertificateList = new LinkedList<X509Certificate>();
		try {
			InputStream in = new FileInputStream(arquivoZipEntrada);
			ZipInputStream zipInputStream = new ZipInputStream(in);

			ZipEntry zipentry = zipInputStream.getNextEntry();
			while (zipentry != null) {
				byte[] buffer = new byte[(int) zipentry.getSize()];
				int offset = 0;
				int numRead = 0;
				while (offset < buffer.length && (numRead = zipInputStream.read(buffer, offset, buffer.length - offset)) >= 0) {
					offset += numRead;
				}
				InputStream bis = new ByteInputStream(buffer, 0, buffer.length);
				CertificateFactory cf = CertificateFactory.getInstance("X.509");
				X509Certificate cert = (X509Certificate) cf.generateCertificate(bis);
				try {
					cert.checkValidity();
					x509CertificateList.add(cert);
				} catch (CertificateExpiredException e) {
					if(this.incluirExpirados){
						x509CertificateList.add(cert);
						System.out.println("Certificado Expirado - " + zipentry.getName());
					}else{
						System.out.println("Certificado Expirado - " + zipentry.getName() + " - nao sera adicionado no JKS");
					}
				} catch (CertificateNotYetValidException e) {
					if(this.incluirExpirados){
						x509CertificateList.add(cert);
						System.out.println("Certificado não válido ainda - " + zipentry.getName());
					}else{
						System.out.println("Certificado não válido ainda - " + zipentry.getName() + " - nao sera adicionado no JKS");
					}
				}
				zipInputStream.closeEntry();
				zipentry = zipInputStream.getNextEntry();
			}
			zipInputStream.close();
			in.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return x509CertificateList;
	}

	public OutputStream gerarJKS(List<X509Certificate> listaCertificados){
		OutputStream out = null;
		try {
			KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
			keystore.load(null, null);
			int indice = 0;
			for (X509Certificate cert : listaCertificados) {
				keystore.setCertificateEntry("ac_" + indice, cert);
				indice++;
			}
			File jks = new File(this.caminhoSaida);
			String diretorioDestino = jks.getParent();
			new File(diretorioDestino).mkdirs();
			out = new FileOutputStream(this.caminhoSaida);
			keystore.store(out, this.senhaKeystore.toCharArray());
			out.close();
			out.flush();
		} catch (Exception e) {
			throw new RuntimeException("Erro ao gerar o arquivo de Keystore - " + e.getCause() + " - " + e.getMessage());
		}
		return out;
	}
	
	public void validacaoLeituraArquivo(File arquivo) {
		if (!arquivo.exists()) {
			throw new RuntimeException("Arquivo Inexistente - " + arquivo.getAbsolutePath());
		}
		if (!arquivo.canRead()) {
			throw new RuntimeException("Sem permissão de Leitura do Arquivo - " + arquivo.getAbsolutePath());
		}
	}
}

Abraços,
Victor Jabur

How to access server MBean properties at weblogic 11g using Java – JMX

Hi,

If you want to get any property of Admin or Managed Server (Weblogic) using Java, then this post will help you.

The Oracle Enterprise Manager have a useful tool for explore MBean (System MBean Browser).

As you can see in the picture bellow:

Do you can to capture any server property desired with these java code:

1 – Reading a property if the application is deployed at server (local connection)

import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.naming.InitialContext;

String serverName = System.getProperty("weblogic.Name");
InitialContext ctx = new InitialContext();
MBeanServer server = (MBeanServer)ctx.lookup("java:comp/env/jmx/runtime");
ObjectName objName = new ObjectName("com.bea:Name=" + serverName + ",Type=Server");
String pathJKS = (String) server.getAttribute(objName, "CustomTrustKeyStoreFileName");

2 – Reading a property if the application is remote (remote connection)

import java.util.Hashtable;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.Context;

  public static void main(String [] args) throws Exception{
    String serverName = "AdminServer";
    String hostName = "192.168.1.192";
    String username = "weblogic";
    String password = "welcome1";
    int port = 10000;
    String protocol = "t3";
    String jndiroot = "/jndi/";
    String mserver = "weblogic.management.mbeanservers.domainruntime";
    JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostName, port, jndiroot + mserver);
    Hashtable h = new Hashtable();
    h.put(Context.SECURITY_PRINCIPAL, username);
    h.put(Context.SECURITY_CREDENTIALS, password);
    h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote");
    JMXConnector connector = JMXConnectorFactory.connect(serviceURL, h);
    ObjectName objName = new ObjectName("com.bea:Name=" + serverName + ",Type=Server");
    String pathJKS = (String) connector.getMBeanServerConnection().getAttribute(objName, "CustomTrustKeyStoreFileName");
    System.out.println(pathJKS);
  }

In the cases above, i’m reading a property that is called “CustomTrustKeyStoreFileName”, that’s a string path of the Trusted Keystore. But many and many properties could be read, for example:

  • CustomIdentityKeyStoreFileName
  • ListenPort
  • UploadDirectoryName

That’s it.

Victor Jabur

Working with Expiration Human Task on Oracle Soa Suite 11g

Hello,

I had that to implement an expiration process and go to leave the main steps here:

1- Creating a new Application: File -> New -> Generic Application -> ApplicationExpirationHT
2- Adding a project to application: Project Name: ProjectExpirationHT Project Type: SOA
3- Select: Empty Composite and click at Finish
4- Make a drag and drop of BPEL Process to your composite.xml screen PS: Choose One Way BPEL Process on template combobox
5- Go to file BPELProcess1.bpel in design mode and drag and drop a Human Task Component
6-Double Click in the green human task icon, click at the green plus button
7-Add a Task parameter, for this example i will make the default input parameter (string), that i will use to set the time of expiration (on duration format)
8-Here goes the magic point; Add the custom outcome action called “EXPIRED”
9-This is the final configuration screen. Your screen should like this:
10-Edit your Humantask1.task file and add an user assignment (weblogic is the default user)
11-This is the main configuration for the task expiration (Deadlines): Check “Expire After” and select the task parameter that exists in your payload variable, for this example is inputstring (/task:task/task:payload/task:Parameter1)
12-This is the final step, when your task expires, will be enter on Expired branch and you could make other things when the task expires
Important Tips-

  1. Your payload parameter should be in a DURATION Format, here is an example (P0Y0M0DT0H0M0S). Here is more details about this default type: http://www.w3.org/TR/xmlschema-2/#duration
  2. When you set the Deadlines on your .task file, the expression for duration should be a parameter of your payload, because the rest of task parameters is READ-ONLY
  3. If your bpel is already created and you want to add the expiration validation, don’t worry, you cannot to recreate all flow, it is enough to add a new branch, copy of the others outcomes expressions and change the status task to EXPIRED, it works !
That is it people, if have any question, invite a email for me or better, add commentary for this post and i can help you !