java.security.Provider.Service#getAttribute ( )源码实例Demo

下面列出了java.security.Provider.Service#getAttribute ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-8   文件: Cipher.java
private static int supports(Service s, String attrName, String value) {
    if (value == null) {
        return S_YES;
    }
    String regexp = s.getAttribute(attrName);
    if (regexp == null) {
        return S_MAYBE;
    }
    return matches(regexp, value) ? S_YES : S_NO;
}
 
源代码2 项目: jdk8u-dev-jdk   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM) as supplied by the specified provider. Note that the specified
 * <code>Provider</code> object does not have to be registered in the
 * provider list.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @param provider the <code>Provider</code> object
 * @return a new <code>TransformService</code>
 * @throws NullPointerException if <code>provider</code>,
 *   <code>algorithm</code>, or <code>mechanismType</code> is
 *   <code>null</code>
 * @throws NoSuchAlgorithmException if a <code>TransformService</code>
 *   implementation for the specified algorithm and mechanism type is not
 *   available from the specified <code>Provider</code> object
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType, Provider provider)
    throws NoSuchAlgorithmException {
    if (mechanismType == null || algorithm == null || provider == null) {
        throw new NullPointerException();
    }

    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    Service s = GetInstance.getService
        ("TransformService", algorithm, provider);
    String value = s.getAttribute("MechanismType");
    if ((value == null && dom) ||
        (value != null && value.equals(mechanismType))) {
        Instance instance = GetInstance.getInstance(s, null);
        TransformService ts = (TransformService) instance.impl;
        ts.algorithm = algorithm;
        ts.mechanism = mechanismType;
        ts.provider = instance.provider;
        return ts;
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码3 项目: jdk8u-jdk   文件: Cipher.java
private static int supports(Service s, String attrName, String value) {
    if (value == null) {
        return S_YES;
    }
    String regexp = s.getAttribute(attrName);
    if (regexp == null) {
        return S_MAYBE;
    }
    return matches(regexp, value) ? S_YES : S_NO;
}
 
源代码4 项目: dragonwell8_jdk   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM).
 *
 * <p>This method uses the standard JCA provider lookup mechanism to
 * locate and instantiate a <code>TransformService</code> implementation
 * of the desired algorithm and <code>MechanismType</code> service
 * attribute. It traverses the list of registered security
 * <code>Provider</code>s, starting with the most preferred
 * <code>Provider</code>. A new <code>TransformService</code> object
 * from the first <code>Provider</code> that supports the specified
 * algorithm and mechanism type is returned.
 *
 * <p> Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @return a new <code>TransformService</code>
 * @throws NullPointerException if <code>algorithm</code> or
 *   <code>mechanismType</code> is  <code>null</code>
 * @throws NoSuchAlgorithmException if no <code>Provider</code> supports a
 *   <code>TransformService</code> implementation for the specified
 *   algorithm and mechanism type
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType)
    throws NoSuchAlgorithmException {
    if (mechanismType == null || algorithm == null) {
        throw new NullPointerException();
    }
    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    List<Service> services = GetInstance.getServices("TransformService", algorithm);
    for (Iterator<Service> t = services.iterator(); t.hasNext(); ) {
        Service s = t.next();
        String value = s.getAttribute("MechanismType");
        if ((value == null && dom) ||
            (value != null && value.equals(mechanismType))) {
            Instance instance = GetInstance.getInstance(s, null);
            TransformService ts = (TransformService) instance.impl;
            ts.algorithm = algorithm;
            ts.mechanism = mechanismType;
            ts.provider = instance.provider;
            return ts;
        }
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码5 项目: dragonwell8_jdk   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM) as supplied by the specified provider. Note that the specified
 * <code>Provider</code> object does not have to be registered in the
 * provider list.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @param provider the <code>Provider</code> object
 * @return a new <code>TransformService</code>
 * @throws NullPointerException if <code>provider</code>,
 *   <code>algorithm</code>, or <code>mechanismType</code> is
 *   <code>null</code>
 * @throws NoSuchAlgorithmException if a <code>TransformService</code>
 *   implementation for the specified algorithm and mechanism type is not
 *   available from the specified <code>Provider</code> object
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType, Provider provider)
    throws NoSuchAlgorithmException {
    if (mechanismType == null || algorithm == null || provider == null) {
        throw new NullPointerException();
    }

    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    Service s = GetInstance.getService
        ("TransformService", algorithm, provider);
    String value = s.getAttribute("MechanismType");
    if ((value == null && dom) ||
        (value != null && value.equals(mechanismType))) {
        Instance instance = GetInstance.getInstance(s, null);
        TransformService ts = (TransformService) instance.impl;
        ts.algorithm = algorithm;
        ts.mechanism = mechanismType;
        ts.provider = instance.provider;
        return ts;
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码6 项目: dragonwell8_jdk   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM) as supplied by the specified provider. The specified provider
 * must be registered in the security provider list.
 *
 * <p>Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @param provider the string name of the provider
 * @return a new <code>TransformService</code>
 * @throws NoSuchProviderException if the specified provider is not
 *   registered in the security provider list
 * @throws NullPointerException if <code>provider</code>,
 *   <code>mechanismType</code>, or <code>algorithm</code> is
 *   <code>null</code>
 * @throws NoSuchAlgorithmException if a <code>TransformService</code>
 *   implementation for the specified algorithm and mechanism type is not
 *   available from the specified provider
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType, String provider)
    throws NoSuchAlgorithmException, NoSuchProviderException {
    if (mechanismType == null || algorithm == null || provider == null) {
        throw new NullPointerException();
    } else if (provider.length() == 0) {
        throw new NoSuchProviderException();
    }
    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    Service s = GetInstance.getService
        ("TransformService", algorithm, provider);
    String value = s.getAttribute("MechanismType");
    if ((value == null && dom) ||
        (value != null && value.equals(mechanismType))) {
        Instance instance = GetInstance.getInstance(s, null);
        TransformService ts = (TransformService) instance.impl;
        ts.algorithm = algorithm;
        ts.mechanism = mechanismType;
        ts.provider = instance.provider;
        return ts;
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码7 项目: jdk8u_jdk   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM).
 *
 * <p>This method uses the standard JCA provider lookup mechanism to
 * locate and instantiate a <code>TransformService</code> implementation
 * of the desired algorithm and <code>MechanismType</code> service
 * attribute. It traverses the list of registered security
 * <code>Provider</code>s, starting with the most preferred
 * <code>Provider</code>. A new <code>TransformService</code> object
 * from the first <code>Provider</code> that supports the specified
 * algorithm and mechanism type is returned.
 *
 * <p> Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @return a new <code>TransformService</code>
 * @throws NullPointerException if <code>algorithm</code> or
 *   <code>mechanismType</code> is  <code>null</code>
 * @throws NoSuchAlgorithmException if no <code>Provider</code> supports a
 *   <code>TransformService</code> implementation for the specified
 *   algorithm and mechanism type
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType)
    throws NoSuchAlgorithmException {
    if (mechanismType == null || algorithm == null) {
        throw new NullPointerException();
    }
    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    List<Service> services = GetInstance.getServices("TransformService", algorithm);
    for (Iterator<Service> t = services.iterator(); t.hasNext(); ) {
        Service s = t.next();
        String value = s.getAttribute("MechanismType");
        if ((value == null && dom) ||
            (value != null && value.equals(mechanismType))) {
            Instance instance = GetInstance.getInstance(s, null);
            TransformService ts = (TransformService) instance.impl;
            ts.algorithm = algorithm;
            ts.mechanism = mechanismType;
            ts.provider = instance.provider;
            return ts;
        }
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码8 项目: TencentKona-8   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM).
 *
 * <p>This method uses the standard JCA provider lookup mechanism to
 * locate and instantiate a <code>TransformService</code> implementation
 * of the desired algorithm and <code>MechanismType</code> service
 * attribute. It traverses the list of registered security
 * <code>Provider</code>s, starting with the most preferred
 * <code>Provider</code>. A new <code>TransformService</code> object
 * from the first <code>Provider</code> that supports the specified
 * algorithm and mechanism type is returned.
 *
 * <p> Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @return a new <code>TransformService</code>
 * @throws NullPointerException if <code>algorithm</code> or
 *   <code>mechanismType</code> is  <code>null</code>
 * @throws NoSuchAlgorithmException if no <code>Provider</code> supports a
 *   <code>TransformService</code> implementation for the specified
 *   algorithm and mechanism type
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType)
    throws NoSuchAlgorithmException {
    if (mechanismType == null || algorithm == null) {
        throw new NullPointerException();
    }
    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    List<Service> services = GetInstance.getServices("TransformService", algorithm);
    for (Iterator<Service> t = services.iterator(); t.hasNext(); ) {
        Service s = t.next();
        String value = s.getAttribute("MechanismType");
        if ((value == null && dom) ||
            (value != null && value.equals(mechanismType))) {
            Instance instance = GetInstance.getInstance(s, null);
            TransformService ts = (TransformService) instance.impl;
            ts.algorithm = algorithm;
            ts.mechanism = mechanismType;
            ts.provider = instance.provider;
            return ts;
        }
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码9 项目: openjdk-jdk8u-backup   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM) as supplied by the specified provider. The specified provider
 * must be registered in the security provider list.
 *
 * <p>Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @param provider the string name of the provider
 * @return a new <code>TransformService</code>
 * @throws NoSuchProviderException if the specified provider is not
 *   registered in the security provider list
 * @throws NullPointerException if <code>provider</code>,
 *   <code>mechanismType</code>, or <code>algorithm</code> is
 *   <code>null</code>
 * @throws NoSuchAlgorithmException if a <code>TransformService</code>
 *   implementation for the specified algorithm and mechanism type is not
 *   available from the specified provider
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType, String provider)
    throws NoSuchAlgorithmException, NoSuchProviderException {
    if (mechanismType == null || algorithm == null || provider == null) {
        throw new NullPointerException();
    } else if (provider.length() == 0) {
        throw new NoSuchProviderException();
    }
    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    Service s = GetInstance.getService
        ("TransformService", algorithm, provider);
    String value = s.getAttribute("MechanismType");
    if ((value == null && dom) ||
        (value != null && value.equals(mechanismType))) {
        Instance instance = GetInstance.getInstance(s, null);
        TransformService ts = (TransformService) instance.impl;
        ts.algorithm = algorithm;
        ts.mechanism = mechanismType;
        ts.provider = instance.provider;
        return ts;
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码10 项目: TencentKona-8   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM) as supplied by the specified provider. The specified provider
 * must be registered in the security provider list.
 *
 * <p>Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @param provider the string name of the provider
 * @return a new <code>TransformService</code>
 * @throws NoSuchProviderException if the specified provider is not
 *   registered in the security provider list
 * @throws NullPointerException if <code>provider</code>,
 *   <code>mechanismType</code>, or <code>algorithm</code> is
 *   <code>null</code>
 * @throws NoSuchAlgorithmException if a <code>TransformService</code>
 *   implementation for the specified algorithm and mechanism type is not
 *   available from the specified provider
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType, String provider)
    throws NoSuchAlgorithmException, NoSuchProviderException {
    if (mechanismType == null || algorithm == null || provider == null) {
        throw new NullPointerException();
    } else if (provider.length() == 0) {
        throw new NoSuchProviderException();
    }
    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    Service s = GetInstance.getService
        ("TransformService", algorithm, provider);
    String value = s.getAttribute("MechanismType");
    if ((value == null && dom) ||
        (value != null && value.equals(mechanismType))) {
        Instance instance = GetInstance.getInstance(s, null);
        TransformService ts = (TransformService) instance.impl;
        ts.algorithm = algorithm;
        ts.mechanism = mechanismType;
        ts.provider = instance.provider;
        return ts;
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码11 项目: TencentKona-8   文件: Cipher.java
private static int supports(Service s, String attrName, String value) {
    if (value == null) {
        return S_YES;
    }
    String regexp = s.getAttribute(attrName);
    if (regexp == null) {
        return S_MAYBE;
    }
    return matches(regexp, value) ? S_YES : S_NO;
}
 
源代码12 项目: openjdk-jdk8u   文件: Cipher.java
private static int supports(Service s, String attrName, String value) {
    if (value == null) {
        return S_YES;
    }
    String regexp = s.getAttribute(attrName);
    if (regexp == null) {
        return S_MAYBE;
    }
    return matches(regexp, value) ? S_YES : S_NO;
}
 
源代码13 项目: Java8CN   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM) as supplied by the specified provider. The specified provider
 * must be registered in the security provider list.
 *
 * <p>Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @param provider the string name of the provider
 * @return a new <code>TransformService</code>
 * @throws NoSuchProviderException if the specified provider is not
 *   registered in the security provider list
 * @throws NullPointerException if <code>provider</code>,
 *   <code>mechanismType</code>, or <code>algorithm</code> is
 *   <code>null</code>
 * @throws NoSuchAlgorithmException if a <code>TransformService</code>
 *   implementation for the specified algorithm and mechanism type is not
 *   available from the specified provider
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType, String provider)
    throws NoSuchAlgorithmException, NoSuchProviderException {
    if (mechanismType == null || algorithm == null || provider == null) {
        throw new NullPointerException();
    } else if (provider.length() == 0) {
        throw new NoSuchProviderException();
    }
    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    Service s = GetInstance.getService
        ("TransformService", algorithm, provider);
    String value = s.getAttribute("MechanismType");
    if ((value == null && dom) ||
        (value != null && value.equals(mechanismType))) {
        Instance instance = GetInstance.getInstance(s, null);
        TransformService ts = (TransformService) instance.impl;
        ts.algorithm = algorithm;
        ts.mechanism = mechanismType;
        ts.provider = instance.provider;
        return ts;
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码14 项目: openjdk-jdk9   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM) as supplied by the specified provider. Note that the specified
 * <code>Provider</code> object does not have to be registered in the
 * provider list.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @param provider the <code>Provider</code> object
 * @return a new <code>TransformService</code>
 * @throws NullPointerException if <code>provider</code>,
 *   <code>algorithm</code>, or <code>mechanismType</code> is
 *   <code>null</code>
 * @throws NoSuchAlgorithmException if a <code>TransformService</code>
 *   implementation for the specified algorithm and mechanism type is not
 *   available from the specified <code>Provider</code> object
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType, Provider provider)
    throws NoSuchAlgorithmException {
    if (mechanismType == null || algorithm == null || provider == null) {
        throw new NullPointerException();
    }

    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    Service s = provider.getService("TransformService", algorithm);
    if (s != null) {
        String value = s.getAttribute("MechanismType");
        if ((value == null && dom) ||
            (value != null && value.equals(mechanismType))) {
            Object obj = s.newInstance(null);
            if (obj instanceof TransformService) {
                TransformService ts = (TransformService) obj;
                ts.algorithm = algorithm;
                ts.mechanism = mechanismType;
                ts.provider = provider;
                return ts;
            }
        }
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available from " + provider.getName());
}
 
源代码15 项目: jdk8u-jdk   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM) as supplied by the specified provider. Note that the specified
 * <code>Provider</code> object does not have to be registered in the
 * provider list.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @param provider the <code>Provider</code> object
 * @return a new <code>TransformService</code>
 * @throws NullPointerException if <code>provider</code>,
 *   <code>algorithm</code>, or <code>mechanismType</code> is
 *   <code>null</code>
 * @throws NoSuchAlgorithmException if a <code>TransformService</code>
 *   implementation for the specified algorithm and mechanism type is not
 *   available from the specified <code>Provider</code> object
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType, Provider provider)
    throws NoSuchAlgorithmException {
    if (mechanismType == null || algorithm == null || provider == null) {
        throw new NullPointerException();
    }

    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    Service s = GetInstance.getService
        ("TransformService", algorithm, provider);
    String value = s.getAttribute("MechanismType");
    if ((value == null && dom) ||
        (value != null && value.equals(mechanismType))) {
        Instance instance = GetInstance.getInstance(s, null);
        TransformService ts = (TransformService) instance.impl;
        ts.algorithm = algorithm;
        ts.mechanism = mechanismType;
        ts.provider = instance.provider;
        return ts;
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码16 项目: JDKSourceCode1.8   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM).
 *
 * <p>This method uses the standard JCA provider lookup mechanism to
 * locate and instantiate a <code>TransformService</code> implementation
 * of the desired algorithm and <code>MechanismType</code> service
 * attribute. It traverses the list of registered security
 * <code>Provider</code>s, starting with the most preferred
 * <code>Provider</code>. A new <code>TransformService</code> object
 * from the first <code>Provider</code> that supports the specified
 * algorithm and mechanism type is returned.
 *
 * <p> Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @return a new <code>TransformService</code>
 * @throws NullPointerException if <code>algorithm</code> or
 *   <code>mechanismType</code> is  <code>null</code>
 * @throws NoSuchAlgorithmException if no <code>Provider</code> supports a
 *   <code>TransformService</code> implementation for the specified
 *   algorithm and mechanism type
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType)
    throws NoSuchAlgorithmException {
    if (mechanismType == null || algorithm == null) {
        throw new NullPointerException();
    }
    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    List<Service> services = GetInstance.getServices("TransformService", algorithm);
    for (Iterator<Service> t = services.iterator(); t.hasNext(); ) {
        Service s = t.next();
        String value = s.getAttribute("MechanismType");
        if ((value == null && dom) ||
            (value != null && value.equals(mechanismType))) {
            Instance instance = GetInstance.getInstance(s, null);
            TransformService ts = (TransformService) instance.impl;
            ts.algorithm = algorithm;
            ts.mechanism = mechanismType;
            ts.provider = instance.provider;
            return ts;
        }
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码17 项目: JDKSourceCode1.8   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM) as supplied by the specified provider. Note that the specified
 * <code>Provider</code> object does not have to be registered in the
 * provider list.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @param provider the <code>Provider</code> object
 * @return a new <code>TransformService</code>
 * @throws NullPointerException if <code>provider</code>,
 *   <code>algorithm</code>, or <code>mechanismType</code> is
 *   <code>null</code>
 * @throws NoSuchAlgorithmException if a <code>TransformService</code>
 *   implementation for the specified algorithm and mechanism type is not
 *   available from the specified <code>Provider</code> object
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType, Provider provider)
    throws NoSuchAlgorithmException {
    if (mechanismType == null || algorithm == null || provider == null) {
        throw new NullPointerException();
    }

    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    Service s = GetInstance.getService
        ("TransformService", algorithm, provider);
    String value = s.getAttribute("MechanismType");
    if ((value == null && dom) ||
        (value != null && value.equals(mechanismType))) {
        Instance instance = GetInstance.getInstance(s, null);
        TransformService ts = (TransformService) instance.impl;
        ts.algorithm = algorithm;
        ts.mechanism = mechanismType;
        ts.provider = instance.provider;
        return ts;
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码18 项目: JDKSourceCode1.8   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM) as supplied by the specified provider. The specified provider
 * must be registered in the security provider list.
 *
 * <p>Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @param provider the string name of the provider
 * @return a new <code>TransformService</code>
 * @throws NoSuchProviderException if the specified provider is not
 *   registered in the security provider list
 * @throws NullPointerException if <code>provider</code>,
 *   <code>mechanismType</code>, or <code>algorithm</code> is
 *   <code>null</code>
 * @throws NoSuchAlgorithmException if a <code>TransformService</code>
 *   implementation for the specified algorithm and mechanism type is not
 *   available from the specified provider
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType, String provider)
    throws NoSuchAlgorithmException, NoSuchProviderException {
    if (mechanismType == null || algorithm == null || provider == null) {
        throw new NullPointerException();
    } else if (provider.length() == 0) {
        throw new NoSuchProviderException();
    }
    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    Service s = GetInstance.getService
        ("TransformService", algorithm, provider);
    String value = s.getAttribute("MechanismType");
    if ((value == null && dom) ||
        (value != null && value.equals(mechanismType))) {
        Instance instance = GetInstance.getInstance(s, null);
        TransformService ts = (TransformService) instance.impl;
        ts.algorithm = algorithm;
        ts.mechanism = mechanismType;
        ts.provider = instance.provider;
        return ts;
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码19 项目: openjdk-jdk8u   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM).
 *
 * <p>This method uses the standard JCA provider lookup mechanism to
 * locate and instantiate a <code>TransformService</code> implementation
 * of the desired algorithm and <code>MechanismType</code> service
 * attribute. It traverses the list of registered security
 * <code>Provider</code>s, starting with the most preferred
 * <code>Provider</code>. A new <code>TransformService</code> object
 * from the first <code>Provider</code> that supports the specified
 * algorithm and mechanism type is returned.
 *
 * <p> Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @return a new <code>TransformService</code>
 * @throws NullPointerException if <code>algorithm</code> or
 *   <code>mechanismType</code> is  <code>null</code>
 * @throws NoSuchAlgorithmException if no <code>Provider</code> supports a
 *   <code>TransformService</code> implementation for the specified
 *   algorithm and mechanism type
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType)
    throws NoSuchAlgorithmException {
    if (mechanismType == null || algorithm == null) {
        throw new NullPointerException();
    }
    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    List<Service> services = GetInstance.getServices("TransformService", algorithm);
    for (Iterator<Service> t = services.iterator(); t.hasNext(); ) {
        Service s = t.next();
        String value = s.getAttribute("MechanismType");
        if ((value == null && dom) ||
            (value != null && value.equals(mechanismType))) {
            Instance instance = GetInstance.getInstance(s, null);
            TransformService ts = (TransformService) instance.impl;
            ts.algorithm = algorithm;
            ts.mechanism = mechanismType;
            ts.provider = instance.provider;
            return ts;
        }
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
源代码20 项目: openjdk-jdk8u   文件: TransformService.java
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM) as supplied by the specified provider. The specified provider
 * must be registered in the security provider list.
 *
 * <p>Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @param provider the string name of the provider
 * @return a new <code>TransformService</code>
 * @throws NoSuchProviderException if the specified provider is not
 *   registered in the security provider list
 * @throws NullPointerException if <code>provider</code>,
 *   <code>mechanismType</code>, or <code>algorithm</code> is
 *   <code>null</code>
 * @throws NoSuchAlgorithmException if a <code>TransformService</code>
 *   implementation for the specified algorithm and mechanism type is not
 *   available from the specified provider
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType, String provider)
    throws NoSuchAlgorithmException, NoSuchProviderException {
    if (mechanismType == null || algorithm == null || provider == null) {
        throw new NullPointerException();
    } else if (provider.length() == 0) {
        throw new NoSuchProviderException();
    }
    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    Service s = GetInstance.getService
        ("TransformService", algorithm, provider);
    String value = s.getAttribute("MechanismType");
    if ((value == null && dom) ||
        (value != null && value.equals(mechanismType))) {
        Instance instance = GetInstance.getInstance(s, null);
        TransformService ts = (TransformService) instance.impl;
        ts.algorithm = algorithm;
        ts.mechanism = mechanismType;
        ts.provider = instance.provider;
        return ts;
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}