当前位置: 首页>>代码示例>>Java>>正文


Java StripesFilter.getConfiguration方法代码示例

本文整理汇总了Java中net.sourceforge.stripes.controller.StripesFilter.getConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java StripesFilter.getConfiguration方法的具体用法?Java StripesFilter.getConfiguration怎么用?Java StripesFilter.getConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sourceforge.stripes.controller.StripesFilter的用法示例。


在下文中一共展示了StripesFilter.getConfiguration方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getKeyMaterialFromConfig

import net.sourceforge.stripes.controller.StripesFilter; //导入方法依赖的package包/类
/**
 * Attempts to load material from which to manufacture a secret key from the Stripes
 * Configuration. If config is unavailable or there is no material configured null
 * will be returned.
 *
 * @return a byte[] of key material, or null
 */
protected static byte[] getKeyMaterialFromConfig() {
    try {
        Configuration config = StripesFilter.getConfiguration();
        if (config != null) {
            String key = config.getBootstrapPropertyResolver().getProperty(CONFIG_ENCRYPTION_KEY);
            if (key != null) {
                return key.getBytes();
            }
        }
    }
    catch (Exception e) {
        log.warn("Could not load key material from configuration.", e);
    }

    return null;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:24,代码来源:CryptoUtil.java

示例2: getValidationMetadata

import net.sourceforge.stripes.controller.StripesFilter; //导入方法依赖的package包/类
/**
 * Get a map of property names to {@link ValidationMetadata} for the {@link ActionBean} class
 * bound to the URL being built. If the URL does not point to an ActionBean class or no
 * validation metadata exists for the ActionBean class then an empty map will be returned.
 * 
 * @return a map of ActionBean property names to their validation metadata
 * @see ValidationMetadataProvider#getValidationMetadata(Class)
 */
protected Map<String, ValidationMetadata> getValidationMetadata() {
    Map<String, ValidationMetadata> validations = null;
    Configuration configuration = StripesFilter.getConfiguration();
    if (configuration != null) {
        Class<? extends ActionBean> beanType = null;
        try {
            beanType = configuration.getActionResolver().getActionBeanType(this.baseUrl);
        }
        catch (UrlBindingConflictException e) {
            // This can be safely ignored
        }

        if (beanType != null) {
            validations = configuration.getValidationMetadataProvider().getValidationMetadata(
                    beanType);
        }
    }

    if (validations == null)
        validations = Collections.emptyMap();

    return validations;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:32,代码来源:UrlBuilder.java

示例3: getErrorMessage

import net.sourceforge.stripes.controller.StripesFilter; //导入方法依赖的package包/类
/**
 * Looks up the specified key in the error message resource bundle. If the
 * bundle is missing or if the resource cannot be found, will return null
 * instead of throwing an exception.
 *
 * @param locale the locale in which to lookup the resource
 * @param key the exact resource key to lookup
 * @return the resource String or null
 */
public static String getErrorMessage(Locale locale, String key) {
    try {
        Configuration config = StripesFilter.getConfiguration();
        ResourceBundle bundle = config.getLocalizationBundleFactory().getErrorMessageBundle(locale);
        return bundle.getString(key);
    }
    catch (MissingResourceException mre) {
        return null;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:20,代码来源:LocalizationUtility.java

示例4: encrypt

import net.sourceforge.stripes.controller.StripesFilter; //导入方法依赖的package包/类
/**
 * Takes in a String, encrypts it and then base64 encodes the resulting byte[] so that it can be
 * transmitted and stored as a String. Can be decrypted by a subsequent call to
 * {@link #decrypt(String)}. Because, null and "" are equivalent to the Stripes binding engine,
 * if {@code input} is null, then it will be encrypted as if it were "".
 * 
 * @param input the String to encrypt and encode
 * @return the encrypted, base64 encoded String
 */
public static String encrypt(String input) {
    if (input == null)
        input = "";

    // encryption is disabled in debug mode
    Configuration configuration = StripesFilter.getConfiguration();
    if (configuration != null && configuration.isDebugMode())
        return input;

    try {
        // First size the output
        Cipher cipher = getCipher(Cipher.ENCRYPT_MODE);
        byte[] inbytes = input.getBytes();
        final int inputLength = inbytes.length;
        int size = cipher.getOutputSize(DISCARD_BYTES + inputLength);
        byte[] output = new byte[size];

        // Then encrypt along with the nonce and the hash code
        byte[] nonce = nextNonce();
        byte[] hash = generateHashCode(nonce, inbytes);
        int index = cipher.update(hash, 0, HASH_CODE_SIZE, output, 0);
        index = cipher.update(nonce, 0, NONCE_SIZE, output, index);
        if (inbytes.length == 0) {
            cipher.doFinal(output, index);
        }
        else {
            cipher.doFinal(inbytes, 0, inbytes.length, output, index);
        }

        // Then base64 encode the bytes
        return Base64.encodeBytes(output, BASE64_OPTIONS);
    }
    catch (Exception e) {
        throw new StripesRuntimeException("Could not encrypt value.", e);
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:46,代码来源:CryptoUtil.java

示例5: UrlBuilder

import net.sourceforge.stripes.controller.StripesFilter; //导入方法依赖的package包/类
/**
 * Constructs a UrlBuilder that references an {@link ActionBean}. Parameters can be added later
 * using addParameter(). If the link is to be used in a page then the ampersand character
 * usually used to separate parameters will be escaped using the XML entity for ampersand.
 * 
 * @param locale the locale to use when formatting parameters with a {@link Formatter}
 * @param beanType {@link ActionBean} class for which the URL will be built
 * @param isForPage true if the URL is to be embedded in a page (e.g. in an anchor of img tag),
 *            false if for some other purpose.
 */
public UrlBuilder(Locale locale, Class<? extends ActionBean> beanType, boolean isForPage) {
    this(locale, isForPage);
    Configuration configuration = StripesFilter.getConfiguration();
    if (configuration != null) {
        this.baseUrl = configuration.getActionResolver().getUrlBinding(beanType);
    }
    else {
        throw new StripesRuntimeException("Unable to lookup URL binding for ActionBean class "
                + "because there is no Configuration object available.");
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:22,代码来源:UrlBuilder.java

示例6: getFormatter

import net.sourceforge.stripes.controller.StripesFilter; //导入方法依赖的package包/类
/**
 * Tries to get a formatter for the given value using the {@link FormatterFactory}. Returns
 * null if there is no {@link Configuration} or {@link FormatterFactory} available (e.g. in a
 * test environment) or if there is no {@link Formatter} configured for the value's type.
 * 
 * @param value the object to be formatted
 * @return a formatter, if one can be found; null otherwise
 */
@SuppressWarnings("rawtypes")
protected Formatter getFormatter(Object value) {
    Configuration configuration = StripesFilter.getConfiguration();
    if (configuration == null)
        return null;

    FormatterFactory factory = configuration.getFormatterFactory();
    if (factory == null)
        return null;

    return factory.getFormatter(value.getClass(), locale, null, null);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:21,代码来源:UrlBuilder.java

示例7: getFormatter

import net.sourceforge.stripes.controller.StripesFilter; //导入方法依赖的package包/类
/**
    * Tries to get a formatter for the given value using the {@link FormatterFactory}. Returns
    * null if there is no {@link Configuration} or {@link FormatterFactory} available (e.g. in a
    * test environment) or if there is no {@link Formatter} configured for the value's type.
    * 
    * @param value the object to be formatted
    * @return a formatter, if one can be found; null otherwise
    */
   @SuppressWarnings("unchecked")
protected Formatter getFormatter(Object value) {
       Configuration configuration = StripesFilter.getConfiguration();
       if (configuration == null)
           return null;

       FormatterFactory factory = configuration.getFormatterFactory();
       if (factory == null)
           return null;

       return factory.getFormatter(value.getClass(), locale, null, null);
   }
 
开发者ID:scarcher2,项目名称:stripes,代码行数:21,代码来源:UrlBuilder.java

示例8: testSts725

import net.sourceforge.stripes.controller.StripesFilter; //导入方法依赖的package包/类
@Test
public void testSts725() {
    int count = 2;
        for (int i = 0; i < count; i++) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("ActionResolver.Packages", "foo.bar");
        MockServletContext mockServletContext = StripesTestFixture.createServletContext();
        try {
            Configuration config = StripesFilter.getConfiguration();
            Assert.assertNotNull(config, "config is null for context " + mockServletContext.getServletContextName());
        } finally {
            mockServletContext.close();
        }
    }
}
 
开发者ID:scarcher2,项目名称:stripes,代码行数:16,代码来源:TestSts725Sts494.java


注:本文中的net.sourceforge.stripes.controller.StripesFilter.getConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。