关于用户注册系统的Refactoring(重整)过程

  public void update() throws Exception
  {
    if (newpassword == null || newpassword.equals("") || newpassword2 == null     || newpassword2.equals("") || !newpassword.equals(newpassword2))
    {
        throw new Exception("something wrong with new Password maybe not
       same!");
    }

    AuthorizationIF auth=AuthorizationFactory.getInstance();
    auth.updatePassword(userid,newpassword);
  }

  /** 获得忘记的密码
  * @param email
  * @return String password
  */
  public String getMypassword(String which) throws Exception{
    AuthorizationIF auth=AuthorizationFactory.getInstance();
    return auth.getPassword(email);
  }


其中的AuthoriztionIF只是一个接口,他能实现updatePassword和getPassword的功能。这一点我在jive中也看到了,不知如何?

AuthorizationIF auth=AuthorizationFactory.getInstance();
工厂方法  
AuthorizationIF 就只是一个接口  

如果仅仅是一个接口,那他怎么能实现那个方法的功能,只有用一个类来继承这个接口,才可以的啊。

我在jive的后台登录时,用户名密码都admin,admin,但是每次都提示错误。也就是forumFactory.hasPermission(ForumPermissions.SYSTEM_ADMIN)是false,但是他是怎么实现的呢?应该是用什么用户名呢?


if (ParamUtils.getBooleanParameter(request,"login")) {
try {
Authorization authToken = AuthorizationFactory.getAuthorization(username, password);
ForumFactory forumFactory = ForumFactory.getInstance(authToken);
if (!forumFactory.hasPermission(ForumPermissions.SYSTEM_ADMIN)) {
throw new UnauthorizedException();
}
session.setAttribute("jive.admin.authorization", authToken);
response.sendRedirect("index.jsp");
return;
}
catch (UnauthorizedException ue) {
errors = true;
errorMessage = "登录失败: 请确认你的用户名和口令都正确";
}
}

去清空你数据库的密码字段