upload a few more classes; implementation and interfaces may change in
the future
This commit is contained in:
parent
e67d371c19
commit
866f5aac0b
@ -1,5 +1,53 @@
|
||||
package com.cringe_studios.cringe_authenticator_library;
|
||||
|
||||
public class Auth {
|
||||
public interface OTP {
|
||||
//TOTP
|
||||
//HOTP
|
||||
|
||||
protected String secret;
|
||||
protected OTPType type;
|
||||
protected OTPAlgorithm algorithm;
|
||||
protected long digits;
|
||||
protected long counter;
|
||||
protected long period;
|
||||
|
||||
//secret: required
|
||||
//algorithm: optional (default SHA1)
|
||||
//digits: optional (default 6)
|
||||
//OTPType: required
|
||||
//period: optional (default 30)
|
||||
//counter: required if hotp
|
||||
public static OTP createNewOTP(OTPType type, String secret, OTPAlgorithm algorithm, long digits, long counter, long periodInSeconds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public long getNextDueTime();
|
||||
|
||||
public String getPin();
|
||||
|
||||
public String updatePin();
|
||||
|
||||
default public String getSecret() {
|
||||
return this.secret;
|
||||
}
|
||||
|
||||
default public OTPType getOTPType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
default public OTPAlgorithm getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
default public long getDigits() {
|
||||
return this.digits;
|
||||
}
|
||||
|
||||
default public long getCounter() {
|
||||
return this.counter;
|
||||
}
|
||||
|
||||
default public long getPeriod() {
|
||||
return this.period;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.cringe_studios.cringe_authenticator_library;
|
||||
|
||||
public enum OTPAlgorithm{
|
||||
SHA1,
|
||||
SHA224,
|
||||
SHA256,
|
||||
SHA384,
|
||||
SHA512;
|
||||
|
||||
public String getJavaName() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.cringe_studios.cringe_authenticator_library.impl;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.MacSpi;
|
||||
import javax.xml.crypto.dsig.spec.HMACParameterSpec;
|
||||
|
||||
import com.cringe_studios.cringe_authenticator_library.OTP;
|
||||
|
||||
//https://datatracker.ietf.org/doc/html/rfc4226
|
||||
public class HOTP implements OTP{
|
||||
|
||||
@Override
|
||||
public long getNextDueTime() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPin() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String updatePin() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.cringe_studios.cringe_authenticator_library.impl;
|
||||
|
||||
import com.cringe_studios.cringe_authenticator_library.OTP;
|
||||
import com.cringe_studios.cringe_authenticator_library.OTPType;
|
||||
|
||||
//https://datatracker.ietf.org/doc/html/rfc6238
|
||||
public class TOTP implements OTP{
|
||||
|
||||
@Override
|
||||
public long getNextDueTime() {
|
||||
// TODO Auto-generated method stub
|
||||
//return this.period System.time;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPin() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String updatePin() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user