/** * Return a control value of the specified type. * * @param type the type OID for the control value we are checking for. * @return the control value if present, null otherwise. */ public Control getControl(ASN1ObjectIdentifier type) { AttributeTypeAndValue found = findControl(type); if (found != null) { if (found.getType().equals(CRMFObjectIdentifiers.id_regCtrl_pkiArchiveOptions)) { return new PKIArchiveControl(PKIArchiveOptions.getInstance(found.getValue())); } if (found.getType().equals(CRMFObjectIdentifiers.id_regCtrl_regToken)) { return new RegTokenControl(DERUTF8String.getInstance(found.getValue())); } if (found.getType().equals(CRMFObjectIdentifiers.id_regCtrl_authenticator)) { return new AuthenticatorControl(DERUTF8String.getInstance(found.getValue())); } } return null; }
private AttributeTypeAndValue findControl(ASN1ObjectIdentifier type) { if (controls == null) { return null; } AttributeTypeAndValue[] tAndVs = controls.toAttributeTypeAndValueArray(); AttributeTypeAndValue found = null; for (int i = 0; i != tAndVs.length; i++) { if (tAndVs[i].getType().equals(type)) { found = tAndVs[i]; break; } } return found; }
public static CmpUtf8Pairs extract(AttributeTypeAndValue[] atvs) { if (atvs == null) { return null; } for (AttributeTypeAndValue atv : atvs) { if (CMPObjectIdentifiers.regInfo_utf8Pairs.equals(atv.getType())) { String regInfoValue = ((ASN1String) atv.getValue()).getString(); return new CmpUtf8Pairs(regInfoValue); } } return null; }
public static AttributeTypeAndValue buildAttributeTypeAndValue(CmpUtf8Pairs utf8Pairs) { ParamUtil.requireNonNull("utf8Pairs", utf8Pairs); return new AttributeTypeAndValue(CMPObjectIdentifiers.regInfo_utf8Pairs, new DERUTF8String(utf8Pairs.encoded())); }