1 43 package net.jforum.sso; 44 45 import net.jforum.dao.DataAccessDriver; 46 import net.jforum.dao.UserDAO; 47 import net.jforum.entities.User; 48 49 55 public class SSOUtils 56 { 57 private String username; 58 private boolean exists = true; 59 private User user; 60 private UserDAO dao; 61 62 72 public boolean userExists(String username) throws Exception 73 { 74 this.username = username; 75 this.dao = DataAccessDriver.getInstance().newUserDAO(); 76 77 this.user = this.dao.selectByName(username); 78 79 this.exists = this.user != null; 80 81 return this.exists; 82 } 83 84 95 public void register(String password, String email) throws Exception 96 { 97 if (this.exists) { 98 return; 99 } 100 101 this.user = new User(); 103 user.setUsername(this.username); 104 user.setPassword(password); 105 user.setEmail(email); 106 user.setActive(1); 107 108 this.dao.addNew(user); 109 } 110 111 116 public User getUser() 117 { 118 return this.user; 119 } 120 } 121 | Popular Tags |