Commit e7c57c72 by Tuukka Kivilahti

blaah, moar stuff

1 parent f5f56775
...@@ -144,7 +144,21 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -144,7 +144,21 @@ public class BarcodeBean implements BarcodeBeanLocal {
} }
/**
* TODO: change user code to be totally random, and to be saved into database
*
* This is nice, but this can be broken too easy
*
* @param user
* @param lenght
* @param bytecount
* @return
*/
private String getUserTextCode(EventUser user, int lenght, int bytecount) { private String getUserTextCode(EventUser user, int lenght, int bytecount) {
return getUserTextCode(user, lenght, bytecount, 0);
}
private String getUserTextCode(EventUser user, int lenght, int bytecount, int loopcount) {
int barcodeLenght = 12; int barcodeLenght = 12;
...@@ -156,10 +170,9 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -156,10 +170,9 @@ public class BarcodeBean implements BarcodeBeanLocal {
// add some random -stuff to start of string // add some random -stuff to start of string
for (int i = lenght - barcode.length(); i > 0; --i) { for (int i = lenght - barcode.length(); i > 0; --i) {
barcode = ((int) (Math.random() * 10.0)) + barcode; barcode = ((int) ((Math.random() * 8.9) +1)) + barcode;
} }
logger.debug(barcode);
BigInteger intCode; BigInteger intCode;
...@@ -176,8 +189,12 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -176,8 +189,12 @@ public class BarcodeBean implements BarcodeBeanLocal {
if(checkCode.compareTo(intCode) != 0) { if(checkCode.compareTo(intCode) != 0) {
logger.error("CheckCode {} : Original {}", checkCode, intCode); logger.error("CheckCode {} : Original {}, text: {} ", checkCode, intCode, textCode);
return "GenError"; // different error messages, so we can tell where the error was
if(loopcount > 10)
return "GenError"; // different error messages, so we can tell where the error was
return getUserTextCode(user, lenght, bytecount, (loopcount +1));
} }
// logger.debug("Geneating hexcode for place {} : {}", place.getId(), textCode); // logger.debug("Geneating hexcode for place {} : {}", place.getId(), textCode);
...@@ -444,7 +461,9 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -444,7 +461,9 @@ public class BarcodeBean implements BarcodeBeanLocal {
BigInteger numbersLeft = new BigInteger(linearFeedbackShiftRegister(original.toByteArray(),bytecount, TEXTCODE_ROTATE_COUNT)); BigInteger numbersLeft = new BigInteger(linearFeedbackShiftRegister(original.toByteArray(),bytecount, TEXTCODE_ROTATE_COUNT));
// logger.debug("numbers afther random {}", numbersLeft);
String converted = ""; String converted = "";
BigInteger divnumber = BigInteger.valueOf(TEXTCODE_CHARACTER_MAP.length()); BigInteger divnumber = BigInteger.valueOf(TEXTCODE_CHARACTER_MAP.length());
......
...@@ -31,7 +31,10 @@ import javax.inject.Inject; ...@@ -31,7 +31,10 @@ import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import fi.codecrew.moya.beans.*; import fi.codecrew.moya.beans.*;
import fi.codecrew.moya.enums.apps.EventPermission;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.*; import fi.codecrew.moya.model.*;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.eticket.EticketView; import fi.codecrew.moya.web.cdiview.eticket.EticketView;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -42,7 +45,7 @@ import org.slf4j.LoggerFactory; ...@@ -42,7 +45,7 @@ import org.slf4j.LoggerFactory;
*/ */
@Named("testView") @Named("testView")
@RequestScoped @RequestScoped
public class TestDataView { public class TestDataView extends GenericCDIView {
private static final Logger logger = LoggerFactory private static final Logger logger = LoggerFactory
.getLogger(TestDataView.class); .getLogger(TestDataView.class);
...@@ -86,7 +89,9 @@ public class TestDataView { ...@@ -86,7 +89,9 @@ public class TestDataView {
} }
public void sendMultibuggageSpam() { public void sendMultibuggageSpam() {
ticketBean.sendTicketEmailToAll(eticketView.getTicketUrl()); if(super.requirePermissions(EventPermission.MANAGE_PRIVATE_PROPERTIES)) {
ticketBean.sendTicketEmailToAll(eticketView.getTicketUrl());
}
} }
public String makeTestData() { public String makeTestData() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!