下面列出了java.security.Provider.Service#getAttribute ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
/**
* 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");
}
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;
}
/**
* 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");
}
/**
* 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");
}
/**
* 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");
}
/**
* 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");
}
/**
* 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");
}
/**
* 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");
}
/**
* 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");
}
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;
}
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;
}
/**
* 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");
}
/**
* 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());
}
/**
* 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");
}
/**
* 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");
}
/**
* 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");
}
/**
* 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");
}
/**
* 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");
}
/**
* 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");
}