-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: problem with password in query
PostPosted: Wed Sep 01, 2004 8:03 pm 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
2.1:

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name = "escola.Utilizador" table = "utilizadores">
<id name = "id" column = "id" unsaved-value = "null">
<generator class = "increment" />
</id>
<many-to-one
name = "relatorio"
column = "rel_relatorios"
class = "escola.Relatorio"
cascade = "all">
</many-to-one>
<property name = "nomeUtilizador" column = "nomeUtilizador" />
<property name = "nomeCompleto" column = "nomeCompleto" />
<property name = "palavraPasse" column = "palavraPasse" />
<property name = "perfil" column = "perfil" />
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
public Utilizador getUtilizador() throws HibernateException {

/**
* ao fazer com que a pp determine a


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 2:46 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
May be a UserType helps. see http://www.hibernate.org/50.html

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 3:01 am 
Regular
Regular

Joined: Thu Aug 05, 2004 2:27 am
Posts: 54
Location: South Africa
you can also consider passing the char[] to the String constructor, and encrypting it.
here's a method to do the encryption for you.

Code:
        /**
    * Returns the encrypted password.
    *
    * @param password
    * @return The encrypted password.
    */
   public static final String encrypt(String password) {
      MessageDigest md;
      String encryptedPass = null;
      try {
         md = MessageDigest.getInstance("SHA");
         byte[] shaBytes = md.digest(password.
               getBytes("UTF-8" ));
         encryptedPass = new BigInteger(shaBytes).toString(16);
      } catch (NoSuchAlgorithmException e) {
         log.error(e);
      } catch (UnsupportedEncodingException e) {
         log.error(e);
      }
      
      return encryptedPass;
   }


Usage : encryptedPass = SomeClass.encrypt(new String(passwordField.getPassword());

please excuse the well off-topic post


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.