import java.rmi.RemoteException;
import domain.Account;
-import domain.Owner;
public interface AccountInterface extends Remote{
*/
private static final long serialVersionUID = 1L;
- private static Administrator admin = null;
private static LinkedList<RuralHouse> addRequest;
private static LinkedList<RuralHouse> removeRequest;
private static LinkedList<Account> newOwnerRequest;
*/
private static final long serialVersionUID = 1L;
private int bookingNumber;
- private boolean isPaid;
private Date bookingDate;
private Client client;
private Offer offer;
this.client=client;
//Booking date is assigned to actual date
this.bookingDate= new java.util.Date(System.currentTimeMillis());
- this.isPaid=false;
}
public void imprimete(){
System.out.println(bookingNumber);
- System.out.println(isPaid);
System.out.println(bookingDate);
System.out.println(client.toString());
System.out.println(offer);
public Date getBookDate() {
return this.bookingDate;
}
-
- public void paid() {
- this.isPaid = true;
- }
-
- public void notPaid() {
- this.isPaid=false;
- }
-
- public boolean isPaid() {
- return isPaid;
- }
-
-
public Client getClient() {
return client;
this.setSize(new Dimension(513, 433));
this.setTitle("Set availability");
- OfferInterface om = null;
jComboBox1 = new JComboBox<RuralHouse>(v);
import common.AdminInterface;
import configuration.___IntNames;
-import domain.Account;
import domain.Owner;
public class OwnerRegistrationGUI extends JFrame {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
private JPanel panel;
private JTextField nameField;
private JTextField userNameField;
private JButton boton2 = null;
private JButton boton3 = null;
private static configuration.ConfigXML c;
-
- // public static ApplicationFacadeInterface facadeInterface;
private JLabel lblNewLabel;
public static void main(String[] args) {
};
scrollPane.setViewportView(table);
tableModel = new DefaultTableModel(null, new String[] {
- "Booking Number", "Is paid", "Booking Date","Name","E-mail", "Telephone" });
+ "Booking Number", "Booking Date","Name","E-mail", "Telephone" });
// Maybe there is a better way to avoid interaction.
// table.setEnabled(false);
btnDenyAddition.setBounds(390, 395, 169, 25);
contentPane.add(btnDenyAddition);
- JButton btnSetAsPaid = new JButton("Set as paid");
- btnSetAsPaid.setBounds(239, 395, 89, 23);
- btnSetAsPaid.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
-
- }
- });
- contentPane.add(btnSetAsPaid);
Enumeration<Booking> en = this.bookings.elements();
Booking book;
while (en.hasMoreElements()) {
book = en.nextElement();
Vector<Object> row = new Vector<Object>();
row.add(book.getBookNumber());
- row.add(book.isPaid());
row.add(book.getBookDate());
row.add(book.getClient().getName());
row.add(book.getClient().getMailAccount());
tableModel = new DefaultTableModel(null, new String[] {
"Name", "E-mail", "Bank Account" });
- //Maybe there is a better way to avoid interaction.
- //table.setEnabled(false);
table.setModel(tableModel);
JButton btnNewButton = new JButton("Confirm Addition");
am.removeOwnerAdditionRequests(table.getSelectedRow());
am.saveInstance();
} catch (RemoteException e1) {
- // TODO Auto-generated catch block
e1.printStackTrace();
}
am.removeOwnerAdditionRequests(table.getSelectedRow());
am.saveInstance();
} catch (RemoteException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
- accounts.remove(table.getSelectedRow());
}
}
});
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/additionalLibs/jcalendar.jar"/>
<classpathentry kind="lib" path="lib/db4o/lib/db4o-8.0.249.16098-all-java5.jar"/>
- <classpathentry kind="lib" path="lib/mail/javax.mail.jar"/>
+ <classpathentry kind="lib" path="lib/javax.mail.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
import javax.mail.MessagingException;
import common.AccountInterface;
+
import dataAccess.DB4oManager;
import domain.Account;
import domain.Administrator;
import java.util.Vector;
import common.AdminInterface;
+
import domain.Account;
import domain.Administrator;
import domain.Owner;
@Override
public Account checkCredentials(String usr, String pwd) {
- Account ac = new Account(usr);
+ Account ac = new Account(SecurityManager.getInstance().calculateHash(usr));
try {
Vector<Account> account = dbMngr.getAccount(ac);
if (SecurityManager.getInstance().isExpectedPassword(pwd.toCharArray(), account
import java.util.Vector;
import common.OfferInterface;
+
import dataAccess.DB4oManager;
import domain.Offer;
import domain.RuralHouse;
import java.rmi.Remote;
import java.rmi.RemoteException;
+
import domain.Account;
public interface AccountInterface extends Remote{
Account alfredoAcc = new Account("userAlfredo", "passAlfredo",
alfredo);
-
Account admin = new Account("admin", "admin", true);
db.store(Administrator.getInstance());
db.store(jonAcc);
}
}
-
-
- public Administrator getAdminData(){
+ public Administrator getAdminData() {
if (c.isDatabaseLocal() == false)
openSDB();
else
try {
-
- List<Administrator> admL = db.query(new Predicate<Administrator>(){
+ List<Administrator> admL = db.query(new Predicate<Administrator>() {
private static final long serialVersionUID = 1L;
public boolean match(Administrator admin) {
}
});
-
-
return admL.get(0);
- }
- finally {
+ } finally {
db.close();
}
else
openDB();
- Vector<Booking> book = new Vector<Booking>() ;
+ Vector<Booking> book = new Vector<Booking>();
try {
offer.createBooking(theDB4oManagerAux.bookingNumber++, cl);
db.store(theDB4oManagerAux); // To store the new value for
// bookingNumber
-
+
db.store(offer);
db.commit();
book = offer.getBookings();
-
+
}
} catch (com.db4o.ext.ObjectNotStorableException e) {
openDB();
try {
- // TODO realize if there is another account with same username.
- // Quite difficult with the f***ing salt
- db.store(acc);
- db.commit();
+ ObjectSet<Account> result = db.queryByExample(new Account(acc
+ .getUsername()));
+ if (result.isEmpty()) {
+ db.store(acc);
+ db.commit();
+ return true;
+ }
} catch (Exception exc) {
exc.printStackTrace();
} finally {
db.close();
}
- return true;
+ return false;
}
// TODO remove account
public boolean removeAccount(Account acc) {
+ if (c.isDatabaseLocal() == false)
+ openSDB();
+ else
+ openDB();
+
+ try {
+ ObjectSet<Account> result = db.queryByExample(new Account(acc
+ .getUsername()));
+ if (!result.isEmpty()) {
+ db.delete(result.get(0));
+ ;
+ db.commit();
+ return true;
+ }
+ } catch (Exception exc) {
+ exc.printStackTrace();
+ } finally {
+ db.close();
+ }
return false;
}
-
- //TODO this method should be improved.
- public void acceptBooking(Offer of){
- Offer off = new Offer(of.getOfferNumber(),of.getRuralHouse(),of.getFirstDay(),of.getLastDay(),of.getPrice());
+
+ // TODO this method should be improved.
+ public void acceptBooking(Offer of) {
+ Offer off = new Offer(of.getOfferNumber(), of.getRuralHouse(),
+ of.getFirstDay(), of.getLastDay(), of.getPrice());
if (c.isDatabaseLocal() == false)
openSDB();
else
this.deleteOffer(result.get(0));
db.store(of);
db.close();
-
+
} catch (Exception e) {
- e.printStackTrace();;
- }
+ e.printStackTrace();
+ ;
+ }
}
-
- public void removeBooking(Booking b){
+
+ public void removeBooking(Booking b) {
if (c.isDatabaseLocal() == false)
openSDB();
else
openDB();
try {
ObjectSet<Booking> result = db.queryByExample(b);
- ObjectSet<Client> result2= db.queryByExample(b.getClient());
+ ObjectSet<Client> result2 = db.queryByExample(b.getClient());
db.delete(result.get(0));
db.delete(result2.get(0));
db.commit();
} catch (Exception e) {
- e.printStackTrace();;
- }finally{
+ e.printStackTrace();
+ ;
+ } finally {
db.close();
}
-
}
}
private boolean admin = false;
- public Account(String usr){
- this.username = SecurityManager.getInstance().calculateHash(usr);
+ public Account(byte[] usr){
+ this.username = usr;
this.salt =null;
this.password = null;
this.owner = null;
}
+
public byte[] getUsername() {
return username;
}
if (getClass() != obj.getClass())
return false;
Account other = (Account) obj;
- if (!Arrays.equals(password, other.password))
- return false;
if (!Arrays.equals(username, other.username))
return false;
return true;
*/
private static final long serialVersionUID = 1L;
private int bookingNumber;
- private boolean isPaid;
private Date bookingDate;
private Client client;
private Offer offer;
this.client=client;
//Booking date is assigned to actual date
this.bookingDate= new java.util.Date(System.currentTimeMillis());
- this.isPaid=false;
}
public void imprimete(){
System.out.println(bookingNumber);
- System.out.println(isPaid);
System.out.println(bookingDate);
System.out.println(client.toString());
System.out.println(offer);
return this.bookingDate;
}
- public void paid() {
- this.isPaid = true;
- }
-
- public void notPaid() {
- this.isPaid=false;
- }
-
- public boolean isPaid() {
- return isPaid;
- }
-
-
-
public Client getClient() {
return client;
}
import businessLogic.OfferManager;
import businessLogic.OwnerManager;
+@SuppressWarnings("deprecation")
public class RMILauncher {
public static void main(String[] args) {