Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package connection;
- import java.io.IOException;
- import java.io.ObjectOutputStream;
- import Converter.Converter;
- import DataSaveSystem.getAllNames;
- import DataSaveSystem.getFullProjekt;
- import Rights.Right;
- import UserData.UserDataBase;
- public class InputListener {
- public InputListener(byte[][] message, ObjectOutputStream output, Right rights, WaitingForMessage waitingForMessage) {
- if(rights!=null){
- try {
- String def = new String(message[0]);
- if(def.equals("get")){
- if(rights.canDownloadt()){
- /*
- * Alle Get Meldunden
- */
- String type = new String(message[1]);
- if(type.equals("allProjectNames")){
- sendMessageBack(getAllNames.getAllNamesInByte(), output);
- }else if(type.equals("fullProject")){
- String name = new String(message[2]);
- sendMessageBack(getFullProjekt.getFullProjekt(name), output);
- }
- }else{
- noPerrmission(output);
- }
- }
- } catch (Exception e) {
- // TODO: handle exception
- }
- }else{
- //Keine Rechte
- try {
- String def = new String(message[0]);
- System.out.println(def);
- if(def.equals("login")){
- try {
- String Username = new String(message[1]);
- String Password = new String(message[2]);
- Right right = UserDataBase.getRightsFormUser(Username, Password);
- if(right!=null){
- waitingForMessage.rights=right;
- sendMessageBack(createSimpleMessage("loginResponse", "true", right.getName()), output);
- System.out.println("login true "+Username+" "+Password+" "+right.getName());
- }else{
- sendMessageBack(createSimpleMessage("loginResponse", "false"), output);
- System.out.println("login false "+Username+" "+Password);
- }
- } catch (Exception e) {
- }
- }else{
- sendMessageBack(createSimpleMessage("error", "noLogin"), output);
- }
- } catch (Exception e) {}
- }
- Converter conver = new Converter();
- conver.createFileformByteArray("TestDataSend.jpg", message[1]);
- //if(message.get(0).equals("ChatMessage")){ChatMessage(message.get(1));}
- }
- private void noPerrmission(ObjectOutputStream output){
- sendMessageBack(createSimpleMessage("error", "noPermission"), output);
- }
- private byte[][] createSimpleMessage(String def,String message){
- byte[][] re = new byte[2][];
- re[0] = def.getBytes();
- re[1] = message.getBytes();
- return re;
- }
- private byte[][] createSimpleMessage(String def,String message,String message2){
- byte[][] re = new byte[3][];
- re[0] = def.getBytes();
- re[1] = message.getBytes();
- re[2] = message2.getBytes();
- return re;
- }
- private void sendMessageBack(byte[][] Message,ObjectOutputStream output){
- try {
- output.writeObject(Message);
- output.flush();
- } catch (IOException e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement