Search in sources :

Example 1 with SlotType

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;
}
Also used : InvalidConfException(org.xipki.common.InvalidConfException) HashSet(java.util.HashSet) SlotType(org.xipki.security.pkcs11.jaxb.SlotType)

Aggregations

HashSet (java.util.HashSet)1 InvalidConfException (org.xipki.common.InvalidConfException)1 SlotType (org.xipki.security.pkcs11.jaxb.SlotType)1