Added comments
parent
c87346a4ab
commit
48595a62bb
|
@ -17,11 +17,17 @@ public class Hmac256Signer extends AbstractJwtSigner {
|
||||||
|
|
||||||
private byte[] passphrase;
|
private byte[] passphrase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a signer with no passphrase
|
||||||
|
*/
|
||||||
public Hmac256Signer() {
|
public Hmac256Signer() {
|
||||||
this(null);
|
this(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a signer with the given passphrase
|
||||||
|
* @param passphrase
|
||||||
|
*/
|
||||||
public Hmac256Signer(byte[] passphrase) {
|
public Hmac256Signer(byte[] passphrase) {
|
||||||
super(HS256);
|
super(HS256);
|
||||||
|
|
||||||
|
|
|
@ -22,20 +22,19 @@ import com.google.common.collect.Lists;
|
||||||
*/
|
*/
|
||||||
public class Rs256Signer extends AbstractJwtSigner {
|
public class Rs256Signer extends AbstractJwtSigner {
|
||||||
|
|
||||||
//TODO: should this class generate a new private key or get one passed into the constructor?
|
|
||||||
private PrivateKey privateKey;
|
private PrivateKey privateKey;
|
||||||
//TODO: where does the publicKey come from?
|
|
||||||
private PublicKey publicKey;
|
private PublicKey publicKey;
|
||||||
|
|
||||||
private Signature signer;
|
private Signature signer;
|
||||||
|
|
||||||
public Rs256Signer() {
|
public Rs256Signer() {
|
||||||
this(null);
|
this(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rs256Signer(PrivateKey privateKey) {
|
public Rs256Signer(PublicKey publicKey, PrivateKey privateKey) {
|
||||||
super("RS256");
|
super("RS256");
|
||||||
|
|
||||||
|
setPublicKey(publicKey);
|
||||||
setPrivateKey(privateKey);
|
setPrivateKey(privateKey);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -96,7 +95,7 @@ public class Rs256Signer extends AbstractJwtSigner {
|
||||||
String c64 = parts.get(1);
|
String c64 = parts.get(1);
|
||||||
String s64 = parts.get(2);
|
String s64 = parts.get(2);
|
||||||
|
|
||||||
String signingInput = h64 + "." + c64 + ".";
|
String signingInput = h64 + "." + c64;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
signer.initVerify(publicKey);
|
signer.initVerify(publicKey);
|
||||||
|
@ -139,4 +138,12 @@ public class Rs256Signer extends AbstractJwtSigner {
|
||||||
this.privateKey = privateKey;
|
this.privateKey = privateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PublicKey getPublicKey() {
|
||||||
|
return publicKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicKey(PublicKey publicKey) {
|
||||||
|
this.publicKey = publicKey;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue