本文整理汇总了Java中org.opensaml.xml.security.credential.UsageType.toString方法的典型用法代码示例。如果您正苦于以下问题:Java UsageType.toString方法的具体用法?Java UsageType.toString怎么用?Java UsageType.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.xml.security.credential.UsageType
的用法示例。
在下文中一共展示了UsageType.toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: marshallAttributes
import org.opensaml.xml.security.credential.UsageType; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
KeyDescriptor keyDescriptor = (KeyDescriptor) xmlObject;
if (keyDescriptor.getUse() != null) {
UsageType use = keyDescriptor.getUse();
// UsageType enum contains more values than are allowed by SAML 2 schema
if (use.equals(UsageType.SIGNING) || use.equals(UsageType.ENCRYPTION)) {
domElement.setAttribute(KeyDescriptor.USE_ATTRIB_NAME, use.toString().toLowerCase());
} else if (use.equals(UsageType.UNSPECIFIED)) {
// emit nothing for unspecified - this is semantically equivalent to non-existent attribute
} else {
// Just in case values are unknowingly added to UsageType in the future...
throw new MarshallingException("KeyDescriptor had illegal value for use attribute: " + use.toString());
}
}
}
示例2: marshallAttributes
import org.opensaml.xml.security.credential.UsageType; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
KeyDescriptor keyDescriptor = (KeyDescriptor) xmlObject;
if (keyDescriptor.getUse() != null) {
UsageType use = keyDescriptor.getUse();
// UsageType enum contains more values than are allowed by SAML 2 schema
if (use.equals(UsageType.SIGNING) || use.equals(UsageType.ENCRYPTION)) {
domElement.setAttribute(KeyDescriptor.USE_ATTRIB_NAME, use.toString().toLowerCase());
} else if (use.equals(UsageType.UNSPECIFIED)) {
//emit nothing for unspecified - this is semantically equivalent to non-existent attribute
} else {
// Just in case values are unknowingly added to UsageType in the future...
throw new MarshallingException("KeyDescriptor had illegal value for use attribute: " + use.toString());
}
}
}
示例3: validateUse
import org.opensaml.xml.security.credential.UsageType; //导入方法依赖的package包/类
/**
* Checks that use attribute has only one of allowed values.
*
* @param keyDescriptor the key descriptor to validate
* @throws ValidationException throw in use attribute does not have a legal value
*/
protected void validateUse(KeyDescriptor keyDescriptor) throws ValidationException {
UsageType use = keyDescriptor.getUse();
if (use == null) {
return;
}
if ( ! use.equals(UsageType.SIGNING)
&& ! use.equals(UsageType.ENCRYPTION)
&& ! use.equals(UsageType.UNSPECIFIED) ) {
throw new ValidationException("Invalid value for use attribute: " + use.toString());
}
}