public static Object[] getAvpsAsCustom(int avpCode, AvpSet set, Class clazz) { try { AvpSet avpSet = set.getAvps(avpCode); Object array = Array.newInstance(clazz, avpSet.size()); int i = 0; Constructor c = clazz.getConstructor(int.class, long.class, int.class, int.class, byte[].class); AvpRepresentation rep = null; for(Avp avp : avpSet) { rep = AvpDictionary.INSTANCE.getAvp(avpCode, avp.getVendorId()); Array.set(array, i++, c.newInstance(rep.getCode(), rep.getVendorId(), rep.getRuleMandatoryAsInt(), rep.getRuleProtectedAsInt(), avp.getRawData())); } return (Object[]) array; } catch (Exception e) { if(logger.isDebugEnabled()) { logger.debug("Failed to obtain AVP with code " + avpCode + " as type Custom (Class '" + clazz.getName() + "').", e); } return (Object[]) Array.newInstance(clazz, 0); } }
public static Object[] getAvpsAsCustom(int avpCode, long vendorId, AvpSet set, Class clazz) { try { AvpSet avpSet = set.getAvps(avpCode, vendorId); Object array = Array.newInstance(clazz, avpSet.size()); int i = 0; AvpRepresentation rep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); Constructor c = clazz.getConstructor(int.class, long.class, int.class, int.class, byte[].class); for(Avp avp : avpSet) { Array.set(array, i++, c.newInstance(rep.getCode(), rep.getVendorId(), rep.getRuleMandatoryAsInt(), rep.getRuleProtectedAsInt(), avp.getRawData())); } return (Object[]) array; } catch (Exception e) { if(logger.isDebugEnabled()) { logger.debug("Failed to obtain AVP with code " + avpCode + " and Vendor-Id " + vendorId + " as type Custom (Class '" + clazz.getName() + "').", e); } return (Object[]) Array.newInstance(clazz, 0); } }
public static Object[] getAvpsAsCustom(int avpCode, long vendorId, AvpSet set, Class clazz) { try { AvpSet avpSet = set.getAvps(avpCode, vendorId); Object array = Array.newInstance(clazz, avpSet.size()); int i = 0; AvpRepresentation rep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); Constructor c = clazz.getConstructor(int.class, long.class, int.class, int.class, byte[].class); for(Avp avp : avpSet) { Array.set(array, i++, c.newInstance(rep.getCode(), rep.getVendorId(), rep.getRuleMandatoryAsInt(), rep.getRuleProtectedAsInt(), avp.getRawData())); } return (Object[]) array; } catch (Exception e) { if(logger.isDebugEnabled()) { logger.debug("Failed to obtain AVP with code " + avpCode + " and Vendor-Id " + vendorId + " as type Custom (Class '" + clazz.getName() + "').", e); } return (Object[]) Array.newInstance(clazz, 0); } }
public static Object getAvpAsCustom(int avpCode, long vendorId, AvpSet set, Class clazz) { try { Avp avp = set.getAvp(avpCode, vendorId); if (avp != null) { AvpRepresentation rep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); Constructor c = null; c = clazz.getConstructor(int.class, long.class, int.class, int.class, byte[].class); return c.newInstance(rep.getCode(), rep.getVendorId(), rep.getRuleMandatoryAsInt(), rep.getRuleProtectedAsInt(), avp.getRawData()); } } catch (Exception e) { if(logger.isDebugEnabled()) { logger.debug("Failed to obtain AVP with code " + avpCode + " and Vendor-Id " + vendorId + " as type Custom (Class '" + clazz.getName() + "').", e); } } return null; }
public static Object getAvpAsCustom(int avpCode, long vendorId, AvpSet set, Class clazz) { try { Avp avp = set.getAvp(avpCode, vendorId); if (avp != null) { AvpRepresentation rep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); Constructor c = null; c = clazz.getConstructor(int.class, long.class, int.class, int.class, byte[].class); return c.newInstance(rep.getCode(), rep.getVendorId(), rep.getRuleMandatoryAsInt(), rep.getRuleProtectedAsInt(), avp.getRawData()); } } catch (Exception e) { if(logger.isDebugEnabled()) { logger.debug("Failed to obtain AVP with code " + avpCode + " and Vendor-Id " + vendorId + " as type Custom (Class '" + clazz.getName() + "').", e); } } return null; }
AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); int mandatoryAvp = avpRep.getRuleMandatoryAsInt(); int protectedAvp = avpRep.getRuleProtectedAsInt();
AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); int mandatoryAvp = avpRep.getRuleMandatoryAsInt(); int protectedAvp = avpRep.getRuleProtectedAsInt();
public static Object[] getAvpsAsCustom(int avpCode, AvpSet set, Class clazz) { try { AvpSet avpSet = set.getAvps(avpCode); Object array = Array.newInstance(clazz, avpSet.size()); int i = 0; Constructor c = clazz.getConstructor(int.class, long.class, int.class, int.class, byte[].class); AvpRepresentation rep = null; for(Avp avp : avpSet) { rep = AvpDictionary.INSTANCE.getAvp(avpCode, avp.getVendorId()); Array.set(array, i++, c.newInstance(rep.getCode(), rep.getVendorId(), rep.getRuleMandatoryAsInt(), rep.getRuleProtectedAsInt(), avp.getRawData())); } return (Object[]) array; } catch (Exception e) { if(logger.isDebugEnabled()) { logger.debug("Failed to obtain AVP with code " + avpCode + " as type Custom (Class '" + clazz.getName() + "').", e); } return (Object[]) Array.newInstance(clazz, 0); } }
private DiameterAvp[] getAvpsInternal(AvpSet set) throws Exception { List<DiameterAvp> avps = new ArrayList<DiameterAvp>(); for (Avp a : set) { AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(a.getCode(), a.getVendorId()); if (avpRep == null) { //log.error("Avp with code: " + a.getCode() + " VendorId: " + a.getVendorId() + " is not listed in dictionary, skipping!"); continue; } else { if (avpRep.getType().equals("Grouped")) { // TODO: There's no info about if AVP has mandatory or protected flags set... GroupedAvpImpl gAVP = new GroupedAvpImpl(a.getCode(), a.getVendorId(), avpRep.getRuleMandatoryAsInt(), avpRep.getRuleProtectedAsInt(), a.getRaw()); gAVP.setExtensionAvps(getAvpsInternal(a.getGrouped())); // This is a grouped AVP... let's make it like that. avps.add(gAVP); } else { // TODO: There's no info about if AVP has mandatory or protected flags set... avps.add(new DiameterAvpImpl(a.getCode(), a.getVendorId(), avpRep.getRuleMandatoryAsInt(), avpRep.getRuleProtectedAsInt(), a.getRaw(), DiameterAvpType.fromString(avpRep.getType()))); } } } return avps.toArray(new DiameterAvp[avps.size()]); }
private DiameterAvp[] getAvpsInternal(AvpSet set) throws Exception { List<DiameterAvp> avps = new ArrayList<DiameterAvp>(); for (Avp a : set) { AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(a.getCode(), a.getVendorId()); if (avpRep == null) { //log.error("Avp with code: " + a.getCode() + " VendorId: " + a.getVendorId() + " is not listed in dictionary, skipping!"); continue; } else { if (avpRep.getType().equals("Grouped")) { // TODO: There's no info about if AVP has mandatory or protected flags set... GroupedAvpImpl gAVP = new GroupedAvpImpl(a.getCode(), a.getVendorId(), avpRep.getRuleMandatoryAsInt(), avpRep.getRuleProtectedAsInt(), a.getRaw()); gAVP.setExtensionAvps(getAvpsInternal(a.getGrouped())); // This is a grouped AVP... let's make it like that. avps.add(gAVP); } else { // TODO: There's no info about if AVP has mandatory or protected flags set... avps.add(new DiameterAvpImpl(a.getCode(), a.getVendorId(), avpRep.getRuleMandatoryAsInt(), avpRep.getRuleProtectedAsInt(), a.getRaw(), DiameterAvpType.fromString(avpRep.getType()))); } } } return avps.toArray(new DiameterAvp[avps.size()]); }
this.userIdentity = new UserIdentityAvpImpl(DiameterShAvpCodes.USER_IDENTITY, DiameterShAvpCodes.SH_VENDOR_ID,rep.getRuleMandatoryAsInt(),rep.getRuleProtectedAsInt(),AvpUtilities.getAvpAsGrouped(DiameterShAvpCodes.USER_IDENTITY, DiameterShAvpCodes.SH_VENDOR_ID, ((DiameterMessageImpl)msg).getGenericData().getAvps()));