diff --git a/openid-connect-common/src/main/java/org/mitre/jwt/encryption/service/JwtEncryptionAndDecryptionService.java b/openid-connect-common/src/main/java/org/mitre/jwt/encryption/service/JwtEncryptionAndDecryptionService.java index 07b4ab746..106c61ae8 100644 --- a/openid-connect-common/src/main/java/org/mitre/jwt/encryption/service/JwtEncryptionAndDecryptionService.java +++ b/openid-connect-common/src/main/java/org/mitre/jwt/encryption/service/JwtEncryptionAndDecryptionService.java @@ -19,6 +19,7 @@ package org.mitre.jwt.encryption.service; import java.util.Collection; import java.util.Map; +import com.nimbusds.jose.EncryptionMethod; import com.nimbusds.jose.JWEAlgorithm; import com.nimbusds.jose.JWEObject; import com.nimbusds.jose.jwk.JWK; @@ -56,6 +57,12 @@ public interface JwtEncryptionAndDecryptionService { */ 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. * Example: public void encryptJwt(EncryptedJWT jwt, String kid); diff --git a/openid-connect-common/src/main/java/org/mitre/jwt/encryption/service/impl/DefaultJwtEncryptionAndDecryptionService.java b/openid-connect-common/src/main/java/org/mitre/jwt/encryption/service/impl/DefaultJwtEncryptionAndDecryptionService.java index cd2015e47..079eca612 100644 --- a/openid-connect-common/src/main/java/org/mitre/jwt/encryption/service/impl/DefaultJwtEncryptionAndDecryptionService.java +++ b/openid-connect-common/src/main/java/org/mitre/jwt/encryption/service/impl/DefaultJwtEncryptionAndDecryptionService.java @@ -32,6 +32,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.common.base.Strings; +import com.nimbusds.jose.EncryptionMethod; import com.nimbusds.jose.JOSEException; import com.nimbusds.jose.JWEAlgorithm; import com.nimbusds.jose.JWEDecrypter; @@ -254,4 +255,23 @@ public class DefaultJwtEncryptionAndDecryptionService implements JwtEncryptionAn 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; + } + + }