-
Notifications
You must be signed in to change notification settings - Fork 3
/
jotpMIDlet.java
55 lines (45 loc) · 1.52 KB
/
jotpMIDlet.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* MIDlet interface to Harry Mantakos <[email protected]> OTP (s/key)
* calculator.
*
* Written by Jan-Frode Myklebust <[email protected]>.
*/
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class jotpMIDlet
extends MIDlet
implements CommandListener {
otp otpwd;
TextField PassField, SeqField, ChallengeField;
int hashalg;
int seq;
private Form mMainForm;
public jotpMIDlet() {
mMainForm = new Form("OneTimePass");
PassField = new TextField("Password", null, 20, TextField.ANY | TextField.PASSWORD);
SeqField = new TextField("Sequence", null, 6, TextField.NUMERIC);
ChallengeField = new TextField("Challenge", null, 10, 0);
mMainForm.append(PassField);
mMainForm.append(SeqField);
mMainForm.append(ChallengeField);
mMainForm.addCommand(new Command("Calculate", Command.OK, 0));
mMainForm.addCommand(new Command("Exit", Command.EXIT, 0));
mMainForm.setCommandListener(this);
}
public void startApp() {
Display.getDisplay(this).setCurrent(mMainForm);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void commandAction(Command c, Displayable s) {
if ( c.getCommandType() == Command.EXIT ) {
notifyDestroyed();
}
if ( c.getCommandType() == Command.OK) {
seq = new Integer(1).valueOf(SeqField.getString()).intValue();
otpwd = new otp(seq, ChallengeField.getString(), PassField.getString(), otp.MD5);
otpwd.calc();
mMainForm.append(new StringItem(null, otpwd.toString()));
}
}
}