use of org.xipki.security.pkcs11.jaxb.SlotType in project xipki by xipki.
the class P11ModuleConf method getSlotIdFilters.
private static Set<P11SlotIdFilter> getSlotIdFilters(SlotsType type) throws InvalidConfException {
if (type == null || CollectionUtil.isEmpty(type.getSlot())) {
return null;
}
Set<P11SlotIdFilter> filters = new HashSet<>();
for (SlotType slotType : type.getSlot()) {
Long slotId = null;
if (slotType.getId() != null) {
String str = slotType.getId().trim();
try {
slotId = StringUtil.startsWithIgnoreCase(str, "0X") ? Long.parseLong(str.substring(2), 16) : Long.parseLong(str);
} catch (NumberFormatException ex) {
String message = "invalid slotId '" + str + "'";
LOG.error(message);
throw new InvalidConfException(message);
}
}
filters.add(new P11SlotIdFilter(slotType.getIndex(), slotId));
}
return filters;
}
Aggregations