本文整理汇总了Java中java.security.Provider.Service.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Service.getAttribute方法的具体用法?Java Service.getAttribute怎么用?Java Service.getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.Provider.Service
的用法示例。
在下文中一共展示了Service.getAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: if
import java.security.Provider.Service; //导入方法依赖的package包/类
/**
* 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());
}
示例2: if
import java.security.Provider.Service; //导入方法依赖的package包/类
/**
* 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");
}
示例3: supports
import java.security.Provider.Service; //导入方法依赖的package包/类
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;
}