gpt4 book ai didi

Java登录/注册系统

转载 作者:行者123 更新时间:2023-12-02 07:25:32 24 4
gpt4 key购买 nike

我想开发一个简单的登录和注册系统。系统需要能够注册用户并允许他们登录。不仅如此,我需要能够识别当前登录的用户是谁。

用户类别

import java.io.Serializable;


public class AuctionHouseUsers implements Serializable {

String userName;
String password;

public AuctionHouseUsers(String aUserName, String aPassword)
{
this.userName = aUserName;
this.password = aPassword;
}
public String getUserName()
{
return userName;
}
public void setUserName(String aUserName)
{
this.userName = aUserName;
}
public String getPassword()
{
return password;
}
public void setPassword(String aPassword)
{
this.password = aPassword;
}
}

拍卖行类

    public class AuctionHouseManager

ArrayList<AuctionHouseUsers> registeredUsers;
ArrayList<AuctionHouseUsers> logedInUsers;


public AuctionHouseManager()

logedInUsers = new ArrayList<AuctionHouseUsers>();
registeredUsers = new ArrayList<AuctionHouseUsers>();
}
public void registerUser(String username, string password)
{
AuctionHouseUsers registeredUser = new AuctionHouseUser(username,password);
registeredUsers.add(tempUser);
}
public void logIn(String username, string password)
{
AuctionHouseUsers logedInUser = new AuctionHouseUser(username,password);
logedInUsers.add(logedInUser);
}

当我要设计一个 GUI 时,我如何跟踪当前登录的人(通过用户名)。

最佳答案

如果这不是作业而是实际的开发项目,我建议您使用 Apache ShiroSpring Security 。两者都提供对身份验证和访问控制(以及更多)的支持。

希望这有帮助。

关于Java登录/注册系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13628283/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com