private static byte[] findSecret(ServletContext ctx, String algorithm) { String secret = ctx.getInitParameter(INIT_SECRET); if (secret == null) { secret = ctx.getInitParameter(INIT_SECRET.toLowerCase()); } return findSecret(secret, algorithm); }
private static byte[] findSecret(ServletContext ctx, String algorithm) { String secret = ctx.getInitParameter(INIT_SECRET); if (secret == null) { secret = ctx.getInitParameter(INIT_SECRET.toLowerCase()); } return findSecret(secret, algorithm); }
/** * Does nothing if the user has disabled the SecretKey cache. This is * useful when dealing with a JCA provider whose SecretKey * implementation is not thread safe. * * Instantiates a SecretKey instance based upon what the user has * specified in the deployment descriptor. The SecretKey is then * stored in application scope where it can be used for all requests. */ public static void initSecret(ServletContext ctx){ if(ctx == null) throw new NullPointerException("ServletContext ctx"); if (log.isDebugEnabled()) log.debug("Storing SecretKey @ " + INIT_SECRET_KEY_CACHE); // you want to create this as few times as possible ctx.setAttribute(INIT_SECRET_KEY_CACHE, new SecretKeySpec(findSecret(ctx), findAlgorithm(ctx))); }
private static byte[] findSecret(ExternalContext ctx, String algorithm) { String secret = ctx.getInitParameter(INIT_SECRET); if (secret == null) { secret = ctx.getInitParameter(INIT_SECRET.toLowerCase()); } return findSecret(secret, algorithm); }
private static byte[] findSecret(ExternalContext ctx, String algorithm) { String secret = ctx.getInitParameter(INIT_SECRET); if (secret == null) { secret = ctx.getInitParameter(INIT_SECRET.toLowerCase()); } return findSecret(secret, algorithm); }
ctx.setAttribute(INIT_SECRET_KEY_CACHE, new SecretKeySpec(findSecret(ctx, algorithm), algorithm));
ctx.setAttribute(INIT_SECRET_KEY_CACHE, new SecretKeySpec(findSecret(ctx, algorithm), algorithm));
secretKey = new SecretKeySpec(findSecret(ctx, algorithm), algorithm);
secretKey = new SecretKeySpec(findSecret(ctx, algorithm), algorithm);