[jboss-user] [JBoss Seam] - Can't inject into an Entity Bean...

seamNoobie do-not-reply at jboss.com
Thu Jan 25 17:12:21 EST 2007


Whats the preferred solution to this:

Given:

  | @Entity
  | @Name("user")
  | public class User implements Serializable {
  | ...
  | 
  | 	@NotNull(message="required")
  | 	@Length(min = 5, max = 15)
  | 	public String getPassword() {
  | 		return password;
  | 	}
  | 
  | 	public void setPassword(String password) {
  | 		this.password = password;
  | 	}
  | ...
  | }
  | 

What I REALLY want to do is this:

  | @Entity
  | @Name("user")
  | public class User implements Serializable {
  | 
  |     @In(create=true)
  |     EncryptionControllerI encryptionController;
  | 
  | ...
  | 
  | 	@NotNull(message="required")
  | 	@Length(min = 5, max = 15)
  | 	public String getPassword() {
  | 		return encryptionController.decrypt(password);;
  | 	}
  | 
  | 	public void setPassword(String password) {
  |                 this.password = encryptionController.encrypt(password);
  | 	}
  | ...
  | }
  | 

Now you can't (it seems) inject into entity beans...

So I move the encryption outside the bean... 
but now that makes my password over the 15 limit... so when I try to save it then I cant...

so I make the max = 15 into max = 30 to accommodate the bigger crypted password... but then some moron puts a password in that 30 !! so that won't work.

I wanted to cryption to be as close to the @Entity as possible so the only other option is to move all the cryption code into the @Entity (which means it has to go to the OS to read the key and create the cyfer which is really poor as it will do it every time an @Entity is created).

Please advise.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4006564#4006564

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4006564



More information about the jboss-user mailing list