public boolean isValid() { // RFC3588, Page 119-120 // One of Acct-Application-Id and Vendor-Specific-Application-Id AVPs // MUST be present. If the Vendor-Specific-Application-Id grouped AVP // is present, it must have an Acct-Application-Id inside. if (this.message.isRequest()) { return false; } else if (!this.hasAccountingRealtimeRequired()) { if (!this.hasVendorSpecificApplicationId()) { return false; } else { if (this.getVendorSpecificApplicationId().getAcctApplicationId() == -1) { return false; } } } return true; }
public void sendAccountingAnswer(AccountingAnswer answer) throws IOException { try { AccountingAnswerImpl aca = (AccountingAnswerImpl) answer; this.serverSession.sendAccountAnswer(new AccountAnswerImpl((Answer) aca.getGenericData())); // FIXME: check this? if (this.serverSession.isStateless()) { endActivity(); } else if(aca.getAccountingRecordType() == AccountingRecordType.STOP_RECORD) { endActivity(); } } catch (org.jdiameter.api.validation.AvpNotAllowedException e) { throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId()); } catch (Exception e) { if(logger.isDebugEnabled()) { logger.debug("Failed to send message, due to: ", e); } throw new IOException("Failed to send message, due to: " + e.getMessage()); } }
public AccountingAnswer createAccountingAnswer(AccountingRequest request) { try { // Get the impl DiameterMessageImpl implRequest = (DiameterMessageImpl) request; // Extract interesting AVPs ArrayList<DiameterAvp> copyAvps = new ArrayList<DiameterAvp>(); copyAvps.add(avpFactory.createAvp(Avp.SESSION_ID, serverSession.getSessions().get(0).getSessionId())); copyAvps.add(avpFactory.createAvp(Avp.ORIGIN_HOST, this.originHost.getBytes())); copyAvps.add(avpFactory.createAvp(Avp.ORIGIN_REALM, this.originRealm.getBytes())); for(DiameterAvp avp : request.getAvps()) { if(avp.getCode() == Avp.ACC_RECORD_NUMBER || avp.getCode() == Avp.ACC_RECORD_TYPE || avp.getCode() == Avp.ACCT_APPLICATION_ID || avp.getCode() == Avp.VENDOR_SPECIFIC_APPLICATION_ID) { copyAvps.add((DiameterAvp) avp.clone()); } } DiameterMessageImpl answer = (DiameterMessageImpl) messageFactory.createMessage(implRequest.getHeader(), copyAvps.toArray(new DiameterAvp[copyAvps.size()])); // This is an answer. Message rawAnswer = answer.getGenericData(); rawAnswer.setRequest(false); rawAnswer.setReTransmitted(false); // just in case. answers never have T flag set return new AccountingAnswerImpl(rawAnswer); } catch (Exception e) { logger.error("", e); } return null; }
break; case AccountingAnswer.commandCode: answer = new AccountingAnswerImpl(receivedMessage); break; case CapabilitiesExchangeAnswer.commandCode:
/** * Create Event object from a JDiameter message (request or answer) * * @return a DiameterMessage object wrapping the request/answer * @throws OperationNotSupportedException */ private DiameterMessage createEvent(Message message) { if (message == null) { throw new NullPointerException("Message argument cannot be null while creating event."); } int commandCode = message.getCommandCode(); if (message.isError()) { return new ErrorAnswerImpl(message); } boolean isRequest = message.isRequest(); switch (commandCode) { case RoCreditControlRequest.commandCode: // CCR/CCA return isRequest ? new RoCreditControlRequestImpl(message) : new RoCreditControlAnswerImpl(message); case AbortSessionAnswer.commandCode: // ASR/ASA return isRequest ? new AbortSessionRequestImpl(message) : new AbortSessionAnswerImpl(message); case SessionTerminationAnswer.commandCode: // STR/STA return isRequest ? new SessionTerminationRequestImpl(message) : new SessionTerminationAnswerImpl(message); case ReAuthAnswer.commandCode: // RAR/RAA return isRequest ? new ReAuthRequestImpl(message) : new ReAuthAnswerImpl(message); case AccountingAnswer.commandCode: // ACR/ACA return isRequest ? new AccountingRequestImpl(message) : new AccountingAnswerImpl(message); default: return new ExtensionDiameterMessageImpl(message); } }
public boolean isValid() { // RFC3588, Page 119-120 // One of Acct-Application-Id and Vendor-Specific-Application-Id AVPs // MUST be present. If the Vendor-Specific-Application-Id grouped AVP // is present, it must have an Acct-Application-Id inside. if (this.message.isRequest()) { return false; } else if (!this.hasAccountingRealtimeRequired()) { if (!this.hasVendorSpecificApplicationId()) { return false; } else { if (this.getVendorSpecificApplicationId().getAcctApplicationId() == -1) { return false; } } } return true; }
/** * Create Event object from a JDiameter message (request or answer) * * @return a DiameterMessage object wrapping the request/answer * @throws OperationNotSupportedException */ private DiameterMessage createEvent(Message message) { if (message == null) { throw new NullPointerException("Message argument cannot be null while creating event."); } int commandCode = message.getCommandCode(); if (message.isError()) { return new ErrorAnswerImpl(message); } boolean isRequest = message.isRequest(); switch (commandCode) { case RoCreditControlRequest.commandCode: // CCR/CCA return isRequest ? new RoCreditControlRequestImpl(message) : new RoCreditControlAnswerImpl(message); case AbortSessionAnswer.commandCode: // ASR/ASA return isRequest ? new AbortSessionRequestImpl(message) : new AbortSessionAnswerImpl(message); case SessionTerminationAnswer.commandCode: // STR/STA return isRequest ? new SessionTerminationRequestImpl(message) : new SessionTerminationAnswerImpl(message); case ReAuthAnswer.commandCode: // RAR/RAA return isRequest ? new ReAuthRequestImpl(message) : new ReAuthAnswerImpl(message); case AccountingAnswer.commandCode: // ACR/ACA return isRequest ? new AccountingRequestImpl(message) : new AccountingAnswerImpl(message); default: return new ExtensionDiameterMessageImpl(message); } }
/** * Create Event object from a JDiameter message (request or answer). * * @return a DiameterMessage object wrapping the request/answer * @throws OperationNotSupportedException */ private DiameterMessage createEvent(final Message message) { if (message == null) { throw new NullPointerException("Message argument cannot be null while creating event."); } final int commandCode = message.getCommandCode(); if (message.isError()) { return new ErrorAnswerImpl(message); } final boolean isRequest = message.isRequest(); switch (commandCode) { case GxCreditControlRequest.commandCode: // CCR/CCA return isRequest ? new GxCreditControlRequestImpl(message) : new GxCreditControlAnswerImpl(message); case AbortSessionAnswer.commandCode: // ASR/ASA return isRequest ? new AbortSessionRequestImpl(message) : new AbortSessionAnswerImpl(message); case SessionTerminationAnswer.commandCode: // STR/STA return isRequest ? new SessionTerminationRequestImpl(message) : new SessionTerminationAnswerImpl(message); case GxReAuthAnswer.commandCode: // RAR/RAA return isRequest ? new GxReAuthRequestImpl(message) : new GxReAuthAnswerImpl(message); case AccountingAnswer.commandCode: // ACR/ACA return isRequest ? new AccountingRequestImpl(message) : new AccountingAnswerImpl(message); default: return new ExtensionDiameterMessageImpl(message); } }
return isRequest ? new AbortSessionRequestImpl(message) : new AbortSessionAnswerImpl(message); case AccountingRequest.commandCode: // ACR/ACA return isRequest ? new AccountingRequestImpl(message) : new AccountingAnswerImpl(message); case CapabilitiesExchangeRequest.commandCode: // CER/CEA return isRequest ? new CapabilitiesExchangeRequestImpl(message) : new CapabilitiesExchangeAnswerImpl(message);
return isRequest ? new AbortSessionRequestImpl(message) : new AbortSessionAnswerImpl(message); case AccountingRequest.commandCode: // ACR/ACA return isRequest ? new AccountingRequestImpl(message) : new AccountingAnswerImpl(message); case CapabilitiesExchangeRequest.commandCode: // CER/CEA return isRequest ? new CapabilitiesExchangeRequestImpl(message) : new CapabilitiesExchangeAnswerImpl(message);
break; case Message.ACCOUNTING_REQUEST: diamMessage = creatingRequest ? new AccountingRequestImpl(msg) : new AccountingAnswerImpl(msg); break; case Message.CAPABILITIES_EXCHANGE_REQUEST: