Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
move LoginOption feature from Server to Client
Browse files Browse the repository at this point in the history
  • Loading branch information
junghoon-vans committed Dec 1, 2019
1 parent 67d12aa commit 6e285e5
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 14 deletions.
1 change: 1 addition & 0 deletions loginOption
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
null null null
14 changes: 6 additions & 8 deletions src/Account/LoginFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.rmi.RemoteException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
Expand Down Expand Up @@ -42,6 +41,7 @@ public class LoginFrame extends JFrame {
private boolean idSelect;
private String[] option;
private ICLogin iCLogin;
private LoginOption loginOption;

private ActionListener actionListener;
private CourceFrame courceFrame;
Expand All @@ -50,15 +50,13 @@ public class LoginFrame extends JFrame {
public LoginFrame(ICLogin iCLogin) {
this.actionListener = new ActionHandler();
this.iCLogin = iCLogin;
this.loginOption = new LoginOption();

try {
option = iCLogin.getOption();
option = loginOption.get();
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

this.setTitle("로그인");
Expand Down Expand Up @@ -167,11 +165,11 @@ public void actionPerformed(ActionEvent e) {
String name = iCLogin.getName();
// 로그인이 되었을 시 실행되는 코드
if(checkLogin.isSelected()) {
iCLogin.setOption("자동로그인", id, name);
loginOption.set("자동로그인", id, name);
}else if(checkId.isSelected()) {
iCLogin.setOption("아이디저장", id, "null");
loginOption.set("아이디저장", id, "null");
}else {
iCLogin.setOption("null", "null", "null");
loginOption.set("null", "null", "null");
}

courceFrame = new CourceFrame(id, name);
Expand Down
32 changes: 32 additions & 0 deletions src/Account/LoginOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package Account;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class LoginOption {

private String[] option = new String[3];;

public void set(String opt, String id, String name) throws IOException {
// TODO Auto-generated method stub
FileWriter fw = new FileWriter("loginOption", false);
fw.write(opt+" "+id+" "+name);
fw.close();
}

public String[] get() throws FileNotFoundException {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(new FileReader("loginOption"));

while(scanner.hasNext()) {
option[0] = scanner.next(); // 로그인 옵션
option[1] = scanner.next(); // id
option[2] = scanner.next(); // names
}
scanner.close();
return option;
}
}
5 changes: 4 additions & 1 deletion src/Cource/CourceFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javax.swing.JFrame;

import Account.LoginFrame;
import Account.LoginOption;
import Enrollment.EnrollBtnPanel;
import Enrollment.EnrollmentPanel;
import Framework.ICApply;
Expand All @@ -40,6 +41,7 @@ public class CourceFrame extends JFrame {

private ICBasket iCBasket;
private ICApply iCApply;
private LoginOption loginOption;

// 선택된 패널
private boolean lecture = false;
Expand Down Expand Up @@ -201,7 +203,8 @@ public void logout() {
loginFrame.setVisible(true);
loginFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try {
iCLogin.setOption("null", "null", "null");
loginOption = new LoginOption();
loginOption.set("null", "null", "null");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down
2 changes: 0 additions & 2 deletions src/Framework/ICLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public interface ICLogin extends Remote {
public void authenticate(String userid, String password) throws FileNotFoundException, InvalidUserException, RemoteException;
public boolean validId(String id) throws FileNotFoundException, RemoteException;
public String getName() throws RemoteException;
public void setOption(String opt, String id, String name) throws IOException, RemoteException;
public String[] getOption() throws FileNotFoundException, RemoteException;
public void addAccount(String id, String pw, String name) throws IOException, RemoteException;

}
6 changes: 3 additions & 3 deletions src/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import javax.swing.JFrame;

import Account.LoginFrame;
import Account.LoginOption;
import Cource.CourceFrame;
import Framework.ICLogin;

Expand All @@ -17,6 +16,7 @@ public class Main {
private static String[] option;

static ICLogin iCLogin = null;
static LoginOption loginOption = new LoginOption();

static LoginFrame loginFrame;
static CourceFrame courceFrame;
Expand All @@ -29,7 +29,7 @@ public static void main(String[] args) {
try {
Constant.registry = LocateRegistry.getRegistry(host);
iCLogin = (ICLogin) Constant.registry.lookup("iCLogin");
option = iCLogin.getOption();
option = loginOption.get();
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
Expand Down

0 comments on commit 6e285e5

Please sign in to comment.