spelling, property access, and cleanup
							parent
							
								
									2ca713c7f2
								
							
						
					
					
						commit
						fb2f2f9792
					
				| 
						 | 
				
			
			@ -19,10 +19,8 @@ import com.google.common.base.Joiner;
 | 
			
		|||
import com.nimbusds.jose.EncryptionMethod;
 | 
			
		||||
import com.nimbusds.jose.JWEAlgorithm;
 | 
			
		||||
import com.nimbusds.jose.JWEHeader;
 | 
			
		||||
import com.nimbusds.jose.JWSHeader;
 | 
			
		||||
import com.nimbusds.jwt.EncryptedJWT;
 | 
			
		||||
import com.nimbusds.jwt.JWTClaimsSet;
 | 
			
		||||
import com.nimbusds.jwt.SignedJWT;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author jricher
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +28,7 @@ import com.nimbusds.jwt.SignedJWT;
 | 
			
		|||
 */
 | 
			
		||||
public class EncryptedAuthRequestUrlBuilder implements AuthRequestUrlBuilder {
 | 
			
		||||
	
 | 
			
		||||
	private JWKSetCacheService encryptors;
 | 
			
		||||
	private JWKSetCacheService encrypterService;
 | 
			
		||||
	
 | 
			
		||||
	/* (non-Javadoc)
 | 
			
		||||
	 * @see org.mitre.openid.connect.client.service.AuthRequestUrlBuilder#buildAuthRequestUrl(org.mitre.openid.connect.config.ServerConfiguration, org.mitre.oauth2.model.RegisteredClient, java.lang.String, java.lang.String, java.lang.String, java.util.Map)
 | 
			
		||||
| 
						 | 
				
			
			@ -77,7 +75,7 @@ public class EncryptedAuthRequestUrlBuilder implements AuthRequestUrlBuilder {
 | 
			
		|||
 | 
			
		||||
		EncryptedJWT jwt = new EncryptedJWT(new JWEHeader(alg, enc), claims);
 | 
			
		||||
		
 | 
			
		||||
		JwtEncryptionAndDecryptionService encryptor = encryptors.getEncrypter(serverConfig.getJwksUri());
 | 
			
		||||
		JwtEncryptionAndDecryptionService encryptor = encrypterService.getEncrypter(serverConfig.getJwksUri());
 | 
			
		||||
		
 | 
			
		||||
		encryptor.encryptJwt(jwt);
 | 
			
		||||
		
 | 
			
		||||
| 
						 | 
				
			
			@ -92,4 +90,18 @@ public class EncryptedAuthRequestUrlBuilder implements AuthRequestUrlBuilder {
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * @return the encrypterService
 | 
			
		||||
	 */
 | 
			
		||||
	public JWKSetCacheService getEncrypterService() {
 | 
			
		||||
		return encrypterService;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * @param encrypterService the encrypterService to set
 | 
			
		||||
	 */
 | 
			
		||||
	public void setEncrypterService(JWKSetCacheService encrypterService) {
 | 
			
		||||
		this.encrypterService = encrypterService;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,7 +41,7 @@ import com.nimbusds.jose.jwk.JWKSet;
 | 
			
		|||
 | 
			
		||||
/**
 | 
			
		||||
 * 
 | 
			
		||||
 * Creates a caching map of JOSE signers/validators and encryptors/decryptors
 | 
			
		||||
 * Creates a caching map of JOSE signers/validators and encrypters/decryptors
 | 
			
		||||
 * keyed on the JWK Set URI. Dynamically loads JWK Sets to create the services.
 | 
			
		||||
 * 
 | 
			
		||||
 * @author jricher
 | 
			
		||||
| 
						 | 
				
			
			@ -56,14 +56,14 @@ public class JWKSetCacheService {
 | 
			
		|||
	private LoadingCache<String, JwtSigningAndValidationService> validators;
 | 
			
		||||
	
 | 
			
		||||
	// map of jwk set uri -> encryption/decryption service built on the keys found in that jwk set
 | 
			
		||||
	private LoadingCache<String, JwtEncryptionAndDecryptionService> encryptors;
 | 
			
		||||
	private LoadingCache<String, JwtEncryptionAndDecryptionService> encrypters;
 | 
			
		||||
 | 
			
		||||
	public JWKSetCacheService() {
 | 
			
		||||
		this.validators = CacheBuilder.newBuilder()
 | 
			
		||||
				.expireAfterWrite(1, TimeUnit.HOURS) // expires 1 hour after fetch
 | 
			
		||||
				.maximumSize(100)
 | 
			
		||||
				.build(new JWKSetVerifierFetcher());
 | 
			
		||||
		this.encryptors = CacheBuilder.newBuilder()
 | 
			
		||||
		this.encrypters = CacheBuilder.newBuilder()
 | 
			
		||||
				.expireAfterWrite(1, TimeUnit.HOURS) // expires 1 hour after fetch
 | 
			
		||||
				.maximumSize(100)
 | 
			
		||||
				.build(new JWKSetEncryptorFetcher());
 | 
			
		||||
| 
						 | 
				
			
			@ -86,7 +86,7 @@ public class JWKSetCacheService {
 | 
			
		|||
 | 
			
		||||
	public JwtEncryptionAndDecryptionService getEncrypter(String jwksUri) {
 | 
			
		||||
		try {
 | 
			
		||||
			return encryptors.get(jwksUri);
 | 
			
		||||
			return encrypters.get(jwksUri);
 | 
			
		||||
		} catch (ExecutionException e) {
 | 
			
		||||
			logger.warn("Couldn't load JWK Set from " + jwksUri, e);
 | 
			
		||||
			return null;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue