Update of /cvsroot/neuclear/neuclear-bet/src/java/org/neuclear/bet
In directory sc8-pr-cvs1:/tmp/cvs-serv10206/src/java/org/neuclear/bet
Modified Files:
BetLostException.java BetNotFoundException.java
BetProcessor.java BetReceipt.java BetRequest.java
Log Message:
EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
Otherwise You will Finaliate.
Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final.
This should hopefully make everything more stable (and secure).
Index: BetLostException.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-bet/src/java/org/neuclear/bet/BetLostException.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** BetLostException.java 20 Sep 2003 23:19:21 -0000 1.1.1.1
--- BetLostException.java 21 Nov 2003 04:42:46 -0000 1.2
***************
*** 7,11 ****
* Time: 5:48:25 PM
*/
! public class BetLostException extends Exception{
}
--- 7,11 ----
* Time: 5:48:25 PM
*/
! public final class BetLostException extends Exception{
}
Index: BetNotFoundException.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-bet/src/java/org/neuclear/bet/BetNotFoundException.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** BetNotFoundException.java 20 Sep 2003 23:19:21 -0000 1.1.1.1
--- BetNotFoundException.java 21 Nov 2003 04:42:46 -0000 1.2
***************
*** 7,10 ****
* Time: 5:47:24 PM
*/
! public class BetNotFoundException extends Exception{
}
--- 7,10 ----
* Time: 5:47:24 PM
*/
! public final class BetNotFoundException extends Exception{
}
Index: BetProcessor.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-bet/src/java/org/neuclear/bet/BetProcessor.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** BetProcessor.java 9 Nov 2003 03:26:39 -0000 1.6
--- BetProcessor.java 21 Nov 2003 04:42:46 -0000 1.7
***************
*** 28,32 ****
* This Class manages the betting process.
*/
! public class BetProcessor implements ResultListener {
/**
* Instantiates the BetProcessor with the required CurrencyController to use for
--- 28,32 ----
* This Class manages the betting process.
*/
! public final class BetProcessor implements ResultListener {
/**
* Instantiates the BetProcessor with the required CurrencyController to use for
***************
*** 35,39 ****
* @param pay
*/
! public BetProcessor(Totalizer tote, CurrencyController pay, String title, String id) {
this.pay = pay;
this.title = title;
--- 35,39 ----
* @param pay
*/
! public BetProcessor(final Totalizer tote, final CurrencyController pay, final String title, final String id) {
this.pay = pay;
this.title = title;
***************
*** 45,62 ****
}
! private CurrencyController pay;
! private String title;
! private String id;
! private Totalizer tote;
! public String getTitle() {
return title;
}
! public String getId() {
return id;
}
! public CurrencyController getPaymentProcessor() {
return pay;
}
--- 45,62 ----
}
! private final CurrencyController pay;
! private final String title;
! private final String id;
! private final Totalizer tote;
! public final String getTitle() {
return title;
}
! public final String getId() {
return id;
}
! public final CurrencyController getPaymentProcessor() {
return pay;
}
***************
*** 68,76 ****
* @return BetReceipt
*/
! public BetReceipt processBet(BetRequest req) throws LowlevelLedgerException, BettingEventExpired {
try {
! HeldTransferReceipt held = getPaymentProcessor().processHeldTransfer(new HeldTransferRequest(req.getBettor(), getPoolAccountID(req.getOutcome()), req.getAmount(), new Date(), req.getOutcome().getEvent().getClosingTime(), req.getComment()));
try {
! String ticket = req.getOutcome().bet(req.getAmount());
tickets.put(ticket, held);
return new BetReceipt(req, ticket);
--- 68,76 ----
* @return BetReceipt
*/
! public final BetReceipt processBet(final BetRequest req) throws LowlevelLedgerException, BettingEventExpired {
try {
! final HeldTransferReceipt held = getPaymentProcessor().processHeldTransfer(new HeldTransferRequest(req.getBettor(), getPoolAccountID(req.getOutcome()), req.getAmount(), new Date(), req.getOutcome().getEvent().getClosingTime(), req.getComment()));
try {
! final String ticket = req.getOutcome().bet(req.getAmount());
tickets.put(ticket, held);
return new BetReceipt(req, ticket);
***************
*** 93,97 ****
! public boolean hasWon(BetReceipt receipt) {
return false;
}
--- 93,97 ----
! public final boolean hasWon(final BetReceipt receipt) {
return false;
}
***************
*** 101,105 ****
}
! private Account getPoolAccountID(EventOutcome outcome) throws LowlevelLedgerException {
try {
return pay.getAccount(getId() + "/" + outcome.getId());
--- 101,105 ----
}
! private Account getPoolAccountID(final EventOutcome outcome) throws LowlevelLedgerException {
try {
return pay.getAccount(getId() + "/" + outcome.getId());
***************
*** 118,133 ****
* @param winSrc
*/
! public void win(EventOutcome winSrc) throws LowlevelLedgerException {
! BettableOutcome winner = tote.makeBettable(winSrc);
! BettingEvent event = winner.getEvent();
//First complete hold of all loosers
! Iterator outcomes = event.listOutcomes();
while (outcomes.hasNext()) {
! BettableOutcome outcome = (BettableOutcome) outcomes.next();
if (!outcome.equals(winner)) {
! Iterator loosers = outcome.listBets();
while (loosers.hasNext()) {
! String ticket = (String) loosers.next();
! HeldTransferReceipt held = (HeldTransferReceipt) tickets.get(ticket);
try {
held.complete(tote.getCurrentTime(), held.getAmount(), "Lost Bet: " + ticket + " on: " + outcome.getId() + " at: " + event.getId());
--- 118,133 ----
* @param winSrc
*/
! public final void win(final EventOutcome winSrc) throws LowlevelLedgerException {
! final BettableOutcome winner = tote.makeBettable(winSrc);
! final BettingEvent event = winner.getEvent();
//First complete hold of all loosers
! final Iterator outcomes = event.listOutcomes();
while (outcomes.hasNext()) {
! final BettableOutcome outcome = (BettableOutcome) outcomes.next();
if (!outcome.equals(winner)) {
! final Iterator loosers = outcome.listBets();
while (loosers.hasNext()) {
! final String ticket = (String) loosers.next();
! final HeldTransferReceipt held = (HeldTransferReceipt) tickets.get(ticket);
try {
held.complete(tote.getCurrentTime(), held.getAmount(), "Lost Bet: " + ticket + " on: " + outcome.getId() + " at: " + event.getId());
***************
*** 144,152 ****
}
}
! double odds = winner.getOdds();
! Iterator winners = winner.listBets();
while (winners.hasNext()) {
! String ticket = (String) winners.next();
! HeldTransferReceipt held = (HeldTransferReceipt) tickets.get(ticket);
try {
try {
--- 144,152 ----
}
}
! final double odds = winner.getOdds();
! final Iterator winners = winner.listBets();
while (winners.hasNext()) {
! final String ticket = (String) winners.next();
! final HeldTransferReceipt held = (HeldTransferReceipt) tickets.get(ticket);
try {
try {
***************
*** 179,188 ****
* @param outcomeSrc
*/
! public void scratch(EventOutcome outcomeSrc) throws LowlevelLedgerException {
! BettableOutcome outcome = tote.makeBettable(outcomeSrc);
! Iterator winners = outcome.listBets();
while (winners.hasNext()) {
! String ticket = (String) winners.next();
! HeldTransferReceipt held = (HeldTransferReceipt) tickets.get(ticket);
try {
held.cancel();
--- 179,188 ----
* @param outcomeSrc
*/
! public final void scratch(final EventOutcome outcomeSrc) throws LowlevelLedgerException {
! final BettableOutcome outcome = tote.makeBettable(outcomeSrc);
! final Iterator winners = outcome.listBets();
while (winners.hasNext()) {
! final String ticket = (String) winners.next();
! final HeldTransferReceipt held = (HeldTransferReceipt) tickets.get(ticket);
try {
held.cancel();
***************
*** 198,209 ****
* @param event
*/
! public void cancelEvent(BettingEvent event) throws LowlevelLedgerException {
! Iterator outcomes = event.listOutcomes();
while (outcomes.hasNext()) {
! BettableOutcome outcome = (BettableOutcome) outcomes.next();
! Iterator bets = outcome.listBets();
while (bets.hasNext()) {
! String ticket = (String) bets.next();
! HeldTransferReceipt held = (HeldTransferReceipt) tickets.get(ticket);
try {
held.cancel();
--- 198,209 ----
* @param event
*/
! public final void cancelEvent(final BettingEvent event) throws LowlevelLedgerException {
! final Iterator outcomes = event.listOutcomes();
while (outcomes.hasNext()) {
! final BettableOutcome outcome = (BettableOutcome) outcomes.next();
! final Iterator bets = outcome.listBets();
while (bets.hasNext()) {
! final String ticket = (String) bets.next();
! final HeldTransferReceipt held = (HeldTransferReceipt) tickets.get(ticket);
try {
held.cancel();
***************
*** 215,222 ****
}
! public Totalizer getTotalizer() {
return tote;
}
! private Map tickets;
}
--- 215,222 ----
}
! public final Totalizer getTotalizer() {
return tote;
}
! private final Map tickets;
}
Index: BetReceipt.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-bet/src/java/org/neuclear/bet/BetReceipt.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** BetReceipt.java 6 Nov 2003 23:47:15 -0000 1.2
--- BetReceipt.java 21 Nov 2003 04:42:46 -0000 1.3
***************
*** 9,14 ****
* Time: 6:20:44 PM
*/
! public class BetReceipt implements Bet {
! public BetReceipt(BetRequest req, String id) {
this.req = req;
}
--- 9,14 ----
* Time: 6:20:44 PM
*/
! public final class BetReceipt implements Bet {
! public BetReceipt(final BetRequest req, final String id) {
this.req = req;
}
***************
*** 21,25 ****
* @return
*/
! public BettableOutcome getOutcome() {
return req.getOutcome(); //To change body of implemented methods use Options | File Templates.
}
--- 21,25 ----
* @return
*/
! public final BettableOutcome getOutcome() {
return req.getOutcome(); //To change body of implemented methods use Options | File Templates.
}
***************
*** 30,34 ****
* @return
*/
! public String getComment() {
return req.getComment(); //To change body of implemented methods use Options | File Templates.
}
--- 30,34 ----
* @return
*/
! public final String getComment() {
return req.getComment(); //To change body of implemented methods use Options | File Templates.
}
***************
*** 39,51 ****
* @return
*/
! public double getAmount() {
return req.getAmount(); //To change body of implemented methods use Options | File Templates.
}
! public Account getBettor() {
return req.getBettor(); //To change body of implemented methods use Options | File Templates.
}
! private BetRequest req;
private String id;
}
--- 39,51 ----
* @return
*/
! public final double getAmount() {
return req.getAmount(); //To change body of implemented methods use Options | File Templates.
}
! public final Account getBettor() {
return req.getBettor(); //To change body of implemented methods use Options | File Templates.
}
! private final BetRequest req;
private String id;
}
Index: BetRequest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-bet/src/java/org/neuclear/bet/BetRequest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** BetRequest.java 6 Nov 2003 23:47:15 -0000 1.2
--- BetRequest.java 21 Nov 2003 04:42:46 -0000 1.3
***************
*** 11,15 ****
public final class BetRequest implements Bet {
! public BetRequest(Account bettor, BettableOutcome outcome, double amount, String comment) {
this.outcome = outcome;
--- 11,15 ----
public final class BetRequest implements Bet {
! public BetRequest(final Account bettor, final BettableOutcome outcome, final double amount, final String comment) {
this.outcome = outcome;
***************
*** 51,58 ****
}
! private BettableOutcome outcome;
! private String comment;
! private double amount;
! private Account bettor;
}
--- 51,58 ----
}
! private final BettableOutcome outcome;
! private final String comment;
! private final double amount;
! private final Account bettor;
}
|