private <T> T createNewTicketValidator(final Class<? extends Cas20ServiceTicketValidator> ticketValidatorClass, final String casServerUrlPrefix, final Class<T> clazz) { if (ticketValidatorClass == null) { return ReflectUtils.newInstance(clazz, casServerUrlPrefix); } return (T) ReflectUtils.newInstance(ticketValidatorClass, casServerUrlPrefix); }
/** * Creates a new instance of the given class by passing the given arguments * to the constructor. * @param className Name of class to be created. * @param args Constructor arguments. * @return New instance of given class. */ public static Object newInstance(final String className, final Object[] args) { try { return newInstance(Class.forName(className), args); } catch (final ClassNotFoundException e) { throw new IllegalArgumentException(className + " not found"); } }
/** * Creates a new instance of the given class by passing the given arguments * to the constructor. * @param className Name of class to be created. * @param args Constructor arguments. * @return New instance of given class. */ public static <T> T newInstance(final String className, final Object... args) { return newInstance(ReflectUtils.<T> loadClass(className), args); }
/** * Gets the configured {@link HostnameVerifier} to use for HTTPS connections * if one is configured for this filter. * @return Instance of specified host name verifier or null if none specified. */ protected HostnameVerifier getHostnameVerifier() { final Class<? extends HostnameVerifier> className = getClass(ConfigurationKeys.HOSTNAME_VERIFIER); final String config = getString(ConfigurationKeys.HOSTNAME_VERIFIER_CONFIG); if (className != null) { if (config != null) { return ReflectUtils.newInstance(className, config); } else { return ReflectUtils.newInstance(className); } } return null; }
public void init(FilterConfig filterConfig) throws ServletException { final String configurationStrategyName = filterConfig.getServletContext().getInitParameter(CONFIGURATION_STRATEGY_KEY); this.configurationStrategy = ReflectUtils.newInstance(ConfigurationStrategyName.resolveToConfigurationStrategy(configurationStrategyName)); this.configurationStrategy.init(filterConfig, getClass()); }
/** * Gets the configured {@link HostnameVerifier} to use for HTTPS connections * if one is configured for this filter. * @param filterConfig Servlet filter configuration. * @return Instance of specified host name verifier or null if none specified. */ protected HostnameVerifier getHostnameVerifier(final FilterConfig filterConfig) { final String className = getPropertyFromInitParams(filterConfig, "hostnameVerifier", null); log.trace("Using hostnameVerifier parameter: " + className); final String config = getPropertyFromInitParams(filterConfig, "hostnameVerifierConfig", null); log.trace("Using hostnameVerifierConfig parameter: " + config); if (className != null) { if (config != null) { return ReflectUtils.newInstance(className, config); } else { return ReflectUtils.newInstance(className); } } return null; }
public void start() throws LifecycleException { super.start(); try { CommonUtils.assertNotNull(this.proxyCallbackUrl, "the proxy callback url cannot be null"); CommonUtils.assertTrue(this.proxyCallbackUrl.startsWith("/"), "proxy callback url must start with \"/\""); PROXY_GRANTING_TICKET_STORAGE = ReflectUtils.newInstance(proxyGrantingTicketStorageClass); } catch (final Exception e) { throw new LifecycleException(e); } logger.info("Startup completed."); }
protected void startInternal() throws LifecycleException { super.startInternal(); try { CommonUtils.assertNotNull(this.proxyCallbackUrl, "the proxy callback url cannot be null"); CommonUtils.assertTrue(this.proxyCallbackUrl.startsWith("/"), "proxy callback url must start with \"/\""); PROXY_GRANTING_TICKET_STORAGE = ReflectUtils.newInstance(proxyGrantingTicketStorageClass); } catch (final Exception e) { throw new LifecycleException(e); } logger.info("Startup completed."); }
protected void startInternal() throws LifecycleException { super.startInternal(); try { CommonUtils.assertNotNull(this.proxyCallbackUrl, "the proxy callback url cannot be null"); CommonUtils.assertTrue(this.proxyCallbackUrl.startsWith("/"), "proxy callback url must start with \"/\""); PROXY_GRANTING_TICKET_STORAGE = ReflectUtils.newInstance(proxyGrantingTicketStorageClass); } catch (final Exception e) { throw new LifecycleException(e); } logger.info("Startup completed."); }
protected void startInternal() throws LifecycleException { super.startInternal(); try { CommonUtils.assertNotNull(this.proxyCallbackUrl, "the proxy callback url cannot be null"); CommonUtils.assertTrue(this.proxyCallbackUrl.startsWith("/"), "proxy callback url must start with \"/\""); PROXY_GRANTING_TICKET_STORAGE = ReflectUtils.newInstance(proxyGrantingTicketStorageClass); } catch (final Exception e) { throw new LifecycleException(e); } logger.info("Startup completed."); }
protected void startInternal() throws LifecycleException { super.startInternal(); try { CommonUtils.assertNotNull(this.proxyCallbackUrl, "the proxy callback url cannot be null"); CommonUtils.assertTrue(this.proxyCallbackUrl.startsWith("/"), "proxy callback url must start with \"/\""); PROXY_GRANTING_TICKET_STORAGE = ReflectUtils.newInstance(proxyGrantingTicketStorageClass); } catch (final Exception e) { throw new LifecycleException(e); } logger.info("Startup completed."); }
/** * Test method for {@link org.jasig.cas.client.util.ReflectUtils#newInstance(java.lang.String, java.lang.Object[])}. */ public void testNewInstanceStringObjectArray() { final Object result = ReflectUtils.newInstance("org.jasig.cas.client.validation.Cas10TicketValidator", new Object[] { "https://localhost/cas" }); assertNotNull(result); }
final TicketValidator validator = (TicketValidator) ReflectUtils.newInstance(validatorClass, new Object[] {propertyMap.get("casServerUrlPrefix")});
final TicketValidator validator = ReflectUtils.newInstance(validatorClass, propertyMap.get("casServerUrlPrefix"));
final Class<? extends UrlPatternMatcherStrategy> ignoreUrlMatcherClass = PATTERN_MATCHER_TYPES.get(ignoreUrlPatternType); if (ignoreUrlMatcherClass != null) { this.ignoreUrlPatternMatcherStrategyClass = ReflectUtils.newInstance(ignoreUrlMatcherClass.getName()); } else { try { logger.trace("Assuming {} is a qualified class name...", ignoreUrlPatternType); this.ignoreUrlPatternMatcherStrategyClass = ReflectUtils.newInstance(ignoreUrlPatternType); } catch (final IllegalArgumentException e) { logger.error("Could not instantiate class [{}]", ignoreUrlPatternType, e); setGatewayStorage(ReflectUtils.newInstance(gatewayStorageClass)); this.authenticationRedirectStrategy = ReflectUtils.newInstance(authenticationRedirectStrategyClass);
protected void initInternal(final FilterConfig filterConfig) throws ServletException { setProxyReceptorUrl(getString(ConfigurationKeys.PROXY_RECEPTOR_URL)); final Class<? extends ProxyGrantingTicketStorage> proxyGrantingTicketStorageClass = getClass(ConfigurationKeys.PROXY_GRANTING_TICKET_STORAGE_CLASS); if (proxyGrantingTicketStorageClass != null) { this.proxyGrantingTicketStorage = ReflectUtils.newInstance(proxyGrantingTicketStorageClass); if (this.proxyGrantingTicketStorage instanceof AbstractEncryptedProxyGrantingTicketStorageImpl) { final AbstractEncryptedProxyGrantingTicketStorageImpl p = (AbstractEncryptedProxyGrantingTicketStorageImpl) this.proxyGrantingTicketStorage; final String cipherAlgorithm = getString(ConfigurationKeys.CIPHER_ALGORITHM); final String secretKey = getString(ConfigurationKeys.SECRET_KEY); p.setCipherAlgorithm(cipherAlgorithm); try { if (secretKey != null) { p.setSecretKey(secretKey); } } catch (final Exception e) { throw new RuntimeException(e); } } } this.millisBetweenCleanUps = getInt(ConfigurationKeys.MILLIS_BETWEEN_CLEAN_UPS); super.initInternal(filterConfig); }