Added gitignore; Common module created; TTResponse created; TTLogger created; Auth RMI created;
This commit is contained in:
parent
ac694a1776
commit
f18d7c4bb4
90 changed files with 844 additions and 2105 deletions
|
|
@ -8,5 +8,7 @@
|
|||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="com.github.cliftonlabs:json-simple:2.1.2" level="project" />
|
||||
<orderEntry type="module" module-name="Commons" />
|
||||
</component>
|
||||
</module>
|
||||
15
Client/src/com/texttwist/client/constants/Config.java
Normal file
15
Client/src/com/texttwist/client/constants/Config.java
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package com.texttwist.client.constants;
|
||||
|
||||
/**
|
||||
* Created by loke on 15/06/2017.
|
||||
*/
|
||||
public class Config {
|
||||
|
||||
private static String RMIServerURI = "localhost";
|
||||
private static Integer RMIServerPort = 9999;
|
||||
|
||||
|
||||
public static String getRMIServerAddress(){
|
||||
return "rmi://".concat(RMIServerURI).concat(":").concat(RMIServerPort.toString());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +1,9 @@
|
|||
package com.texttwist.client.pages;
|
||||
|
||||
import com.texttwist.client.constants.Palette;
|
||||
import com.texttwist.client.ui.TTContainer;
|
||||
import com.texttwist.client.ui.TTImage;
|
||||
import oracle.jrockit.jfr.JFR;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by loke on 13/06/2017.
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ public class Game extends Page {
|
|||
-1,
|
||||
root);
|
||||
|
||||
|
||||
TTGameBox searchUserBar = new TTGameBox(
|
||||
new Point(150, 90),
|
||||
new Dimension(250, 40),
|
||||
|
|
@ -134,8 +133,6 @@ public class Game extends Page {
|
|||
new Font(Palette.inputBox_font.getFontName(), Font.BOLD, 40),
|
||||
null,
|
||||
"00:00");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.texttwist.client.pages;
|
||||
import com.texttwist.client.constants.Palette;
|
||||
import com.texttwist.client.ui.*;
|
||||
import models.TTResponse;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.concurrent.Callable;
|
||||
|
|
@ -8,13 +10,14 @@ import java.util.concurrent.Callable;
|
|||
public class Home extends Page {
|
||||
|
||||
private TTContainer loginDataContainer;
|
||||
private HomeManager homeManager;
|
||||
private TTContainer logoContainer;
|
||||
|
||||
public Home(JFrame window) {
|
||||
super(window);
|
||||
homeManager = new HomeManager();
|
||||
createUIComponents();
|
||||
window.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -46,7 +49,14 @@ public class Home extends Page {
|
|||
@Override
|
||||
public Object call() throws Exception {
|
||||
//TODO CHIAMA API PER LOGIN E SE TUTTO OKEY MANDA A PAGINA DEL MENU
|
||||
return new Menu(Page.window);
|
||||
TTResponse res = homeManager.login(usernameField.getText(), String.valueOf(passwordField.getPassword()));
|
||||
if (res.code == 200){
|
||||
//OK, go to next page and show popup
|
||||
return new Menu(window);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "Login Failes");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
loginDataContainer);
|
||||
|
|
|
|||
33
Client/src/com/texttwist/client/pages/HomeManager.java
Normal file
33
Client/src/com/texttwist/client/pages/HomeManager.java
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package com.texttwist.client.pages;
|
||||
import com.texttwist.client.constants.Config;
|
||||
import interfaces.ITTAuth;
|
||||
import models.TTResponse;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.rmi.Naming;
|
||||
import java.rmi.NotBoundException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* Created by loke on 15/06/2017.
|
||||
*/
|
||||
public class HomeManager {
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
String baseUrl = Config.getRMIServerAddress().concat("/auth");
|
||||
|
||||
public HomeManager(){
|
||||
}
|
||||
|
||||
public TTResponse login(String userName, String password) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
System.out.print(password);
|
||||
ITTAuth auth = (ITTAuth) Naming.lookup(baseUrl);
|
||||
return auth.login(userName, password);
|
||||
}
|
||||
|
||||
public TTResponse logout(String userName, String token) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
ITTAuth auth = (ITTAuth) Naming.lookup(baseUrl);
|
||||
return auth.logout(userName, token);
|
||||
}
|
||||
}
|
||||
|
|
@ -12,9 +12,9 @@ import java.util.concurrent.TimeUnit;
|
|||
/**
|
||||
* Created by loke on 13/06/2017.
|
||||
*/
|
||||
public class TTPasswordField extends TTInputBox{
|
||||
public class TTPasswordField extends JPasswordField{
|
||||
|
||||
private String placeholder = "Password";
|
||||
private String placeholder = "";
|
||||
|
||||
public TTPasswordField(Point position, Dimension dimension, JPanel parent) {
|
||||
super();
|
||||
|
|
@ -24,22 +24,7 @@ public class TTPasswordField extends TTInputBox{
|
|||
setBounds(position.x, position.y, dimension.width, dimension.height);
|
||||
setPreferredSize(dimension);
|
||||
setForeground(Palette.fontColor);
|
||||
setPlaceholder(placeholder);
|
||||
|
||||
addKeyListener(new KeyAdapter() {
|
||||
//If wish to have multiple inheritance...
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
super.keyPressed(e);
|
||||
String a = getText();
|
||||
String l = new String();
|
||||
for (int i = 0; i < a.length(); ++i) {
|
||||
l+="*";
|
||||
}
|
||||
setText(l);
|
||||
|
||||
}
|
||||
});
|
||||
setText(placeholder);
|
||||
|
||||
parent.add(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue