quarta-feira, 23 de maio de 2012

Tutorial - Configuração JAAS JBoss 6.1

Fala pessoal,

Vou descrever um pequeno tutorial de como configurar o JAAS no JBoss 6.1 Final e capturar o usuário em sua aplicação após a autenticação. Como é meu primeiro tutorial, dúvidas e sugestões são bem vindas!

1º Passo: Alterar o arquivo "jboss-6.1.0.Final/server/default/conf/login-config.xml" adicionando a política de autenticação utilizada na apliacação

    
        
            java:/lugarcerto
            SELECT U.SENHA FROM USUARIO U WHERE U.EMAIL=?
            SELECT P.DS_PERFIL, 'Roles' FROM USUARIO U
       INNER JOIN PERFIL P ON U.PERFIL_ID_PERFIL = P.ID_PERFIL WHERE U.EMAIL=?
     MD5
     hex
        
    
Pontos importantes:
Linha 1: nome da configuração
Linha 3: Nome da classe que implementará o processo de login, neste caso utilizaremos uma classe do próprio jboss, "DatabaseServerLoginModule". Informarei no final do tutorial um link para outro tutorial, no qual a classe login module é implementada.
Linha 4: Nome do JNDI Name
Linha 5: SQL para buscar a senha forme um identificador, no caso foi utilizado o email como identificador do usuário.
Linha 6: SQL para buscar as roles(papéis) necessários para autenticar no sistema. Caso o usuário no banco não tenha o papel configurado, o acesso não é liberado. Estas roles serão configuradas mais a frente, no arquivo web.xml
Linha 8 e 9: Definição do algoritmo e enoding referente a senha. Isto é muito importante, caso o encoding do Hash utilizado para gerar a senha não seja o mesmo configurado neste arquivo, a autenticação não será liberada!


terça-feira, 10 de janeiro de 2012

HTTP Status Codes

Informational
  • 100 - Continue
    A status code of 100 indicates that (usually the first) part of a request has been received without any problems, and that the rest of the request should now be sent.
  • 101 - Switching Protocols
    HTTP 1.1 is just one type of protocol for transferring data on the web, and a status code of 101 indicates that the server is changing to the protocol it defines in the "Upgrade" header it returns to the client. For example, when requesting a page, a browser might receive a statis code of 101, followed by an "Upgrade" header showing that the server is changing to a different version of HTTP.

Successful

  • 200 - OK
    The 200 status code is by far the most common returned. It means, simply, that the request was received and understood and is being processed.
  • 201 - Created
    A 201 status code indicates that a request was successful and as a result, a resource has been created (for example a new page).
  • 202 - Accepted
    The status code 202 indicates that server has received and understood the request, and that it has been accepted for processing, although it may not be processed immediately.
  • 203 - Non-Authoritative Information
    A 203 status code means that the request was received and understood, and that information sent back about the response is from a third party, rather than the original server. This is virtually identical in meaning to a 200 status code.
  • 204 - No Content
    The 204 status code means that the request was received and understood, but that there is no need to send any data back.
  • 205 - Reset Content
    The 205 status code is a request from the server to the client to reset the document from which the original request was sent. For example, if a user fills out a form, and submits it, a status code of 205 means the server is asking the browser to clear the form.
  • 206 - Partial Content
    A status code of 206 is a response to a request for part of a document. This is used by advanced caching tools, when a user agent requests only a small part of a page, and just that section is returned.

quinta-feira, 5 de janeiro de 2012

Update Mozilla Firefox from repository

Hi,

this tip is to update your mozilla firefox from repository:

$ sudo -i
# add-apt-repository ppa:mozillateam/firefox-stable
# apt-get update && apt-get dist-upgrade -y
 
Source: http://www.tiagohillebrandt.eti.br/blog/2011/03/
instalando-o-firefox-4-no-ubuntu-via-repositorio/ 

terça-feira, 3 de janeiro de 2012

Received fatal alert: unexpected_message / SoapUI

Hi,

do you get this exception in your Soap UI when you request one WebService with SSL autentication?

javax.net.ssl.SSLException: Received fatal alert: unexpected_message


Add this param for your JVM in your init script (installdir/bin/soapui.sh or installdir\bin\ soapUI-3.6.1.vmoptions)

-Dsun.security.ssl.allowUnsafeRenegotiation=true
Hi, below one tip for IllegalArgumentException:

the command (keytool -list -v -keystore) for show some information about your keystore throws this exception below:

keytool -list -v -keystore certificado.javaks
Insira a senha do armazenamento de chaves:

Tipo de armazenamento de chaves: JKS
Fornecedor de armazenamento de chaves: SUN

erro de keytool: java.lang.IllegalArgumentException: unknown format type at
java.lang.IllegalArgumentException: unknown format type at

try change the jdk version, appears to be some incompatibility. Works for me.

jdk version that threw the exception:
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

works jdk version:
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)

My OS is Ubuntu 10.10

thread:
http://www.guj.com.br/java/126669-erro-importa-certificado-digitado