⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 standardfunctionfactory.java

📁 sunxacml源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                                getSupportedFunctions());
        // add DivideFunction
        generalFunctions.addAll((new DivideFunctionCluster()).
                                getSupportedFunctions());
        // add ModFunction
        generalFunctions.addAll((new ModFunctionCluster()).
                                getSupportedFunctions());
        // add AbsFunction
        generalFunctions.addAll((new AbsFunctionCluster()).
                                getSupportedFunctions());
        // add RoundFunction
        generalFunctions.addAll((new RoundFunctionCluster()).
                                getSupportedFunctions());
        // add FloorFunction
        generalFunctions.addAll((new FloorFunctionCluster()).
                                getSupportedFunctions());
        // add DateMathFunction
        generalFunctions.addAll((new DateMathFunctionCluster()).
                                getSupportedFunctions());
        // add general functions from BagFunction
        generalFunctions.addAll((new GeneralBagFunctionCluster()).
                                getSupportedFunctions());
        // add NumericConvertFunction
        generalFunctions.addAll((new NumericConvertFunctionCluster()).
                                getSupportedFunctions());
        // add StringNormalizeFunction
        generalFunctions.addAll((new StringNormalizeFunctionCluster()).
                                getSupportedFunctions());
        // add general functions from SetFunction
        generalFunctions.addAll((new GeneralSetFunctionCluster()).
                                getSupportedFunctions());
        // add the XACML 2.0 string functions
        generalFunctions.addAll((new StringFunctionCluster()).
                                getSupportedFunctions());


        generalAbstractFunctions = new HashMap(conditionAbstractFunctions);

        // add the map function's proxy
        try {
            generalAbstractFunctions.put(new URI(MapFunction.NAME_MAP),
                                         new MapFunctionProxy());
        } catch (URISyntaxException e) {
            // this shouldn't ever happen, but just in case...
            throw new IllegalArgumentException("invalid function name");
        }
    }

    /**
     * Returns a FunctionFactory that will only provide those functions that
     * are usable in Target matching. This method enforces a singleton
     * model, meaning that this always returns the same instance, creating
     * the factory if it hasn't been requested before. This is the default
     * model used by the <code>FunctionFactory</code>, ensuring quick
     * access to this factory.
     *
     * @return a <code>FunctionFactory</code> for target functions
     */
    public static StandardFunctionFactory getTargetFactory() {
        if (targetFactory == null) {
            synchronized (StandardFunctionFactory.class) {
                if (targetFunctions == null)
                    initTargetFunctions();
                if (targetFactory == null)
                    targetFactory =
                        new StandardFunctionFactory(targetFunctions,
                                                    targetAbstractFunctions);
            }
        }

        return targetFactory;
    }

    /**
     * Returns a FuntionFactory that will only provide those functions that
     * are usable in the root of the Condition. These Functions are a
     * superset of the Target functions. This method enforces a singleton
     * model, meaning that this always returns the same instance, creating
     * the factory if it hasn't been requested before. This is the default
     * model used by the <code>FunctionFactory</code>, ensuring quick
     * access to this factory.
     *
     * @return a <code>FunctionFactory</code> for condition functions
     */
    public static StandardFunctionFactory getConditionFactory() {
        if (conditionFactory == null) {
            synchronized (StandardFunctionFactory.class) {
                if (conditionFunctions == null)
                    initConditionFunctions();
                if (conditionFactory == null)
                    conditionFactory =
                        new StandardFunctionFactory(conditionFunctions,
                                                    conditionAbstractFunctions);
            }
        }

        return conditionFactory;
    }

    /**
     * Returns a FunctionFactory that provides access to all the functions.
     * These Functions are a superset of the Condition functions. This method
     * enforces a singleton model, meaning that this always returns the same
     * instance, creating the factory if it hasn't been requested before.
     * This is the default model used by the <code>FunctionFactory</code>,
     * ensuring quick access to this factory.
     *
     * @return a <code>FunctionFactory</code> for all functions
     */
    public static StandardFunctionFactory getGeneralFactory() {
        if (generalFactory == null) {
            synchronized (StandardFunctionFactory.class) {
                if (generalFunctions == null) {
                    initGeneralFunctions();
                    generalFactory =
                        new StandardFunctionFactory(generalFunctions,
                                                    generalAbstractFunctions);
                }
            }
        }
        
        return generalFactory;
    }

    /**
     * Returns the identifiers supported for the given version of XACML.
     * Because this factory supports identifiers from all versions of the
     * XACML specifications, this method is useful for getting a list of
     * which specific identifiers are supported by a given version of XACML.
     *
     * @param xacmlVersion a standard XACML identifier string, as provided
     *                     in <code>PolicyMetaData</code>
     *
     * @return a <code>Set</code> of identifiers
     *
     * @throws UnknownIdentifierException if the version string is unknown
     */
    public static Set getStandardFunctions(String xacmlVersion) {
        // FIXME: collecting the identifiers needs to be implemented..
        throw new RuntimeException("This method isn't implemented yet.");
    }

    /**
     * Returns the set of abstract functions that this standard factory
     * supports as a mapping of identifier to proxy.
     *
     * @return a <code>Map</code> mapping <code>URI</code>s to
     *         <code>FunctionProxy</code>s
     */
    public static Map getStandardAbstractFunctions(String xacmlVersion) {
        // FIXME: collecting the identifiers needs to be implemented..
        throw new RuntimeException("This method isn't implemented yet.");
    }

    /**
     * A convenience method that returns a proxy containing newly created
     * instances of <code>BaseFunctionFactory</code>s that are correctly
     * supersetted and contain the standard functions and abstract functions.
     * These factories allow adding support for new functions.
     *
     * @return a new proxy containing new factories supporting the standard
     *         functions
     */
    public static FunctionFactoryProxy getNewFactoryProxy() {
        // first off, make sure everything's been initialized
        getGeneralFactory();

        // now create the new instances
        FunctionFactory newGeneral =
            new BaseFunctionFactory(generalFunctions,
                                    generalAbstractFunctions);

        FunctionFactory newCondition =
            new BaseFunctionFactory(newGeneral, conditionFunctions,
                                    conditionAbstractFunctions);

        FunctionFactory newTarget =
            new BaseFunctionFactory(newCondition, targetFunctions,
                                    targetAbstractFunctions);

        return new BasicFunctionFactoryProxy(newTarget, newCondition,
                                             newGeneral);
    }

    /**
     * Always throws an exception, since support for new functions may not be
     * added to a standard factory.
     *
     * @param function the <code>Function</code> to add to the factory
     *
     * @throws UnsupportedOperationException always
     */
    public void addFunction(Function function)
        throws IllegalArgumentException
    {
        throw new UnsupportedOperationException("a standard factory cannot " +
                                                "support new functions");
    }

    /**
     * Always throws an exception, since support for new functions may not be
     * added to a standard factory.
     *
     * @param proxy the <code>FunctionProxy</code> to add to the factory
     * @param identity the function's identifier
     *
     * @throws UnsupportedOperationException always
     */
    public void addAbstractFunction(FunctionProxy proxy,
                                    URI identity)
        throws IllegalArgumentException
    {
        throw new UnsupportedOperationException("a standard factory cannot " +
                                                "support new functions");
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -