added encryption method list to encryption/decryption service

pull/516/head
Justin Richer 2013-09-16 16:02:43 -04:00
parent 6605877a1b
commit aeab1ac3cb
2 changed files with 27 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package org.mitre.jwt.encryption.service;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import com.nimbusds.jose.EncryptionMethod;
import com.nimbusds.jose.JWEAlgorithm; import com.nimbusds.jose.JWEAlgorithm;
import com.nimbusds.jose.JWEObject; import com.nimbusds.jose.JWEObject;
import com.nimbusds.jose.jwk.JWK; import com.nimbusds.jose.jwk.JWK;
@ -56,6 +57,12 @@ public interface JwtEncryptionAndDecryptionService {
*/ */
public Collection<JWEAlgorithm> getAllEncryptionAlgsSupported(); public Collection<JWEAlgorithm> getAllEncryptionAlgsSupported();
/**
* Get the list of all encryption methods supported by this service.
* @return
*/
public Collection<EncryptionMethod> getAllEncryptionEncsSupported();
/** /**
* TODO add functionality for encrypting and decrypting using a specified key id. * TODO add functionality for encrypting and decrypting using a specified key id.
* Example: public void encryptJwt(EncryptedJWT jwt, String kid); * Example: public void encryptJwt(EncryptedJWT jwt, String kid);

View File

@ -32,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.nimbusds.jose.EncryptionMethod;
import com.nimbusds.jose.JOSEException; import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWEAlgorithm; import com.nimbusds.jose.JWEAlgorithm;
import com.nimbusds.jose.JWEDecrypter; import com.nimbusds.jose.JWEDecrypter;
@ -254,4 +255,23 @@ public class DefaultJwtEncryptionAndDecryptionService implements JwtEncryptionAn
return algs; return algs;
} }
/* (non-Javadoc)
* @see org.mitre.jwt.encryption.service.JwtEncryptionAndDecryptionService#getAllEncryptionEncsSupported()
*/
@Override
public Collection<EncryptionMethod> getAllEncryptionEncsSupported() {
Set<EncryptionMethod> encs = new HashSet<EncryptionMethod>();
for (JWEEncrypter encrypter : encrypters.values()) {
encs.addAll(encrypter.supportedEncryptionMethods());
}
for (JWEDecrypter decrypter : decrypters.values()) {
encs.addAll(decrypter.supportedEncryptionMethods());
}
return encs;
}
} }