public String toString() { StringBuffer sb = new StringBuffer(); sb.append("name: ").append(this.getName()).append(", code: ").append(this.getCode()).append(", vendor: ").append(this.getVendorId()).append(", weak: ") .append(this.isWeak()).append(", grouped: ").append(this.isGrouped()).append(", type: ").append(this.getType()).append(", multiplicity: ") .append(this.getMultiplicityIndicator()); if (this.isGrouped()) { for (AvpRepresentation child : this.getChildren()) { String childStr = child.toString().replace("\n", "\n---"); sb.append("\n---" + childStr); } } return sb.toString(); }
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 void parseDictionary(InputStream is) throws Exception { // we override default conf here. this.stackDictionary = (DictionaryImpl) DictionarySingleton.getDictionary(is); this.avpMap.clear(); this.nameToCodeMap.clear(); //dont like that.... // fill AVP Map for (org.jdiameter.api.validation.AvpRepresentation value:this.stackDictionary.getAvpMap().values()) { AvpRepresentation avp = new AvpRepresentation((AvpRepresentationImpl) value); this.avpMap.put(avp, avp); this.nameToCodeMap.put(avp.getName(), avp); } }
public boolean isAllowed(int avpCode, long vendorId) { if (this.isGrouped()) { // make better get ? for (AvpRepresentation rep : this.children) { if (rep.getCode() == avpCode && rep.getVendorId() == vendorId) { return rep.isAllowed(); } else { continue; } } return true; } else { return false; } }
public static Object getAvp(String avpName, AvpSet set) { AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpName); if(avpRep != null) { return getAvp(avpRep.getCode(), avpRep.getVendorId(), set); } return null; }
AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); int mandatoryAvp = avpRep.getRuleMandatoryAsInt(); int protectedAvp = avpRep.getRuleProtectedAsInt(); return (DiameterAvp) avpConstructor.newInstance(avpCode, vendorId, mandatoryAvp, protectedAvp, value != null ? value : new byte[]{}, DiameterAvpType.fromString(avpRep.getType()));
private static DiameterAvpType getAvpType(int avpCode, long vendorId) { AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); return avpRep != null ? DiameterAvpType.fromString(avpRep.getType()) : null; }
AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(a.getCode(), a.getVendorId()); if(avpRep != null) { if(avpRep.isGrouped()) { avps.add(new DiameterAvpImpl(a.getCode(), a.getVendorId(), a.isMandatory() ? DiameterAvp.FLAG_RULE_MUST : DiameterAvp.FLAG_RULE_MUSTNOT, a.isEncrypted() ? DiameterAvp.FLAG_RULE_MUST : DiameterAvp.FLAG_RULE_MUSTNOT, a.getRaw(), DiameterAvpType.fromString(avpRep.getType())));
DiameterAvpType avpType = DiameterAvpType.fromString(avpRep.getType()); boolean isMandatoryAvp = !(avpRep.getRuleMandatory().equals("mustnot") || avpRep.getRuleMandatory().equals("shouldnot")); boolean isProtectedAvp = avpRep.getRuleProtected().equals("must");
AvpRepresentation(AvpRepresentationImpl clone) { this(-1, clone.getCode(), clone.getVendorId(), clone.getMultiplicityIndicator(), clone.getName()); this.allowed = clone.isAllowed(); this.grouped = clone.isGrouped(); this.positionIndex = clone.getPositionIndex(); this.weak = clone.isWeak(); this._mandatory = clone.isMandatory(); this._protected = clone.isProtected(); this.description = clone.getDescription(); this.mayEncrypt = clone.isMayEncrypt(); this.ruleMandatory = clone.getRuleMandatory(); this.ruleProtected = clone.getRuleProtected(); this.ruleVendorBit = clone.getRuleVendorBit(); this.type = clone.getType(); if (this.multiplicityIndicator.equals(_MP_NOT_ALLOWED)) this.allowed = false; // copy others. if (isGrouped()) { for (Object o : clone.getChildren()) { AvpRepresentationImpl avpImpl = (AvpRepresentationImpl) o; this.children.add(new AvpRepresentation(avpImpl)); } this.children = Collections.unmodifiableList(this.children); } }
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()));
/** * @param code * @param vendorId * @return */ private AvpRepresentation getMapKey(int code, long vendorId) { return new AvpRepresentation(code, vendorId); }
protected Object getAvp(String avpName) { AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpName); if(avpRep != null) { return getAvp(avpRep.getCode(), avpRep.getVendorId()); } return null; }
AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); int mandatoryAvp = avpRep.getRuleMandatoryAsInt(); int protectedAvp = avpRep.getRuleProtectedAsInt(); return (DiameterAvp) avpConstructor.newInstance(avpCode, vendorId, mandatoryAvp, protectedAvp, value != null ? value : new byte[]{}, DiameterAvpType.fromString(avpRep.getType()));
public boolean isAllowed(int avpCode, long vendorId) { if (this.isGrouped()) { // make better get ? for (AvpRepresentation rep : this.children) { if (rep.getCode() == avpCode && rep.getVendorId() == vendorId) { return rep.isAllowed(); } else { continue; } } return true; } else { return false; } }
private static DiameterAvpType getAvpType(int avpCode, long vendorId) { AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId); return avpRep != null ? DiameterAvpType.fromString(avpRep.getType()) : null; }
AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(a.getCode(), a.getVendorId()); if(avpRep != null) { if(avpRep.isGrouped()) { avps.add(new DiameterAvpImpl(a.getCode(), a.getVendorId(), a.isMandatory() ? DiameterAvp.FLAG_RULE_MUST : DiameterAvp.FLAG_RULE_MUSTNOT, a.isEncrypted() ? DiameterAvp.FLAG_RULE_MUST : DiameterAvp.FLAG_RULE_MUSTNOT, a.getRaw(), DiameterAvpType.fromString(avpRep.getType())));
DiameterAvpType avpType = DiameterAvpType.fromString(avpRep.getType()); boolean isMandatoryAvp = !(avpRep.getRuleMandatory().equals("mustnot") || avpRep.getRuleMandatory().equals("shouldnot")); boolean isProtectedAvp = avpRep.getRuleProtected().equals("must");
AvpRepresentation(AvpRepresentationImpl clone) { this(-1, clone.getCode(), clone.getVendorId(), clone.getMultiplicityIndicator(), clone.getName()); this.allowed = clone.isAllowed(); this.grouped = clone.isGrouped(); this.positionIndex = clone.getPositionIndex(); this.weak = clone.isWeak(); this._mandatory = clone.isMandatory(); this._protected = clone.isProtected(); this.description = clone.getDescription(); this.mayEncrypt = clone.isMayEncrypt(); this.ruleMandatory = clone.getRuleMandatory(); this.ruleProtected = clone.getRuleProtected(); this.ruleVendorBit = clone.getRuleVendorBit(); this.type = clone.getType(); if (this.multiplicityIndicator.equals(_MP_NOT_ALLOWED)) { this.allowed = false; } // copy others. if (isGrouped()) { for (Object o : clone.getChildren()) { AvpRepresentationImpl avpImpl = (AvpRepresentationImpl) o; this.children.add(new AvpRepresentation(avpImpl)); } this.children = Collections.unmodifiableList(this.children); } }
/** * @param code * @param vendorId * @return */ private AvpRepresentation getMapKey(int code, long vendorId) { return new AvpRepresentation(code, vendorId); }