Search in sources :

Example 11 with DiameterIdentity

use of net.java.slee.resource.diameter.base.events.avp.DiameterIdentity in project jain-slee.diameter by RestComm.

the class HSSClientChildSbb method updatePSIActivation.

public String updatePSIActivation(String publicIdentity, String data, String destinationRealm, String destinationHost) throws IOException {
    UserIdentityAvp publicIdentityAvp = createUserIdentityAvp(publicIdentity, null);
    ProfileUpdateRequest pur = diameterShClientMessageFactory.createProfileUpdateRequest(publicIdentityAvp, DataReferenceType.PSI_ACTIVATION, data.getBytes());
    pur.setAuthSessionState(AuthSessionStateType.NO_STATE_MAINTAINED);
    // Set destination -- Realm is mandatory, host is optional
    pur.setDestinationRealm(new DiameterIdentity(destinationRealm));
    if (destinationHost != null) {
        pur.setDestinationHost(new DiameterIdentity(destinationHost));
    }
    ShClientActivity activity = getShClientActivity();
    activity.sendProfileUpdateRequest(pur);
    // Store request for future matching
    storeRequestInACI(activity, pur);
    // Return Session-Id, may be used as identifier
    return activity.getSessionId();
}
Also used : ShClientActivity(net.java.slee.resource.diameter.sh.client.ShClientActivity) ProfileUpdateRequest(net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest) DiameterIdentity(net.java.slee.resource.diameter.base.events.avp.DiameterIdentity) UserIdentityAvp(net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)

Example 12 with DiameterIdentity

use of net.java.slee.resource.diameter.base.events.avp.DiameterIdentity in project jain-slee.diameter by RestComm.

the class HSSClientChildSbb method getIMSPublicIdentity.

public String getIMSPublicIdentity(String publicIdentity, byte[] msisdn, int[] identitySets, String destinationRealm, String destinationHost) throws IOException {
    UserIdentityAvp publicIdentityAvp = createUserIdentityAvp(publicIdentity, msisdn);
    UserDataRequest udr = diameterShClientMessageFactory.createUserDataRequest(publicIdentityAvp, DataReferenceType.IMS_PUBLIC_IDENTITY);
    udr.setAuthSessionState(AuthSessionStateType.NO_STATE_MAINTAINED);
    IdentitySetType[] typeIdentitySets = new IdentitySetType[identitySets.length];
    for (int i = 0; i < identitySets.length; i++) {
        typeIdentitySets[i] = IdentitySetType.fromInt(identitySets[i]);
    }
    udr.setIdentitySets(typeIdentitySets);
    // Set destination -- Realm is mandatory, host is optional
    udr.setDestinationRealm(new DiameterIdentity(destinationRealm));
    if (destinationHost != null) {
        udr.setDestinationHost(new DiameterIdentity(destinationHost));
    }
    ShClientActivity activity = getShClientActivity();
    activity.sendUserDataRequest(udr);
    // Store request for future matching
    storeRequestInACI(activity, udr);
    // Return Session-Id, may be used as identifier
    return activity.getSessionId();
}
Also used : ShClientActivity(net.java.slee.resource.diameter.sh.client.ShClientActivity) UserDataRequest(net.java.slee.resource.diameter.sh.events.UserDataRequest) DiameterIdentity(net.java.slee.resource.diameter.base.events.avp.DiameterIdentity) UserIdentityAvp(net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp) IdentitySetType(net.java.slee.resource.diameter.sh.events.avp.IdentitySetType)

Example 13 with DiameterIdentity

use of net.java.slee.resource.diameter.base.events.avp.DiameterIdentity in project smscgateway by RestComm.

the class ChargingSbb method setupChargingRequestInterface.

// public void onActivityEndEvent(ActivityEndEvent event, ActivityContextInterface aci) {
// logger.info(" Activity Ended[" + aci.getActivity() + "]");
// }
// Setup charging request
public void setupChargingRequestInterface(ChargingMedium chargingType, Sms sms) {
    if (logger.isFineEnabled()) {
        logger.fine("ChargingSbb: received message for process charging process: chargingType=" + chargingType + ", message=[" + sms + "]");
    }
    ChargingData chargingData = new ChargingData();
    chargingData.setSms(sms);
    chargingData.setChargingType(chargingType);
    this.setChargingData(chargingData);
    String sourceAddress = sms.getSourceAddr();
    int sourceTon = sms.getSourceAddrTon();
    String originatorSccpAddress = sms.getOriginatorSccpAddress();
    String origMoServiceCentreAddressDA = sms.getOrigMoServiceCentreAddressDA();
    if (origMoServiceCentreAddressDA == null) {
        origMoServiceCentreAddressDA = smscPropertiesManagement.getServiceCenterGt(sms.getSmsSet().getNetworkId());
    }
    String recipientAddress = sms.getSmsSet().getDestAddr();
    int destTon = sms.getSmsSet().getDestAddrTon();
    int dataCodingScheme = sms.getDataCoding();
    String interfaceId = Integer.toString(sms.getSmsSet().getNetworkId());
    String interfaceText = sms.getOrigEsmeName();
    try {
        DiameterIdentity destHost = null;
        if (smscPropertiesManagement.getDiameterDestHost() != null && !smscPropertiesManagement.getDiameterDestHost().equals("")) {
            // destHost = new DiameterIdentity("aaa://" +
            // smscPropertiesManagement.getDiameterDestHost() + ":" +
            // smscPropertiesManagement.getDiameterDestPort());
            destHost = new DiameterIdentity(smscPropertiesManagement.getDiameterDestHost());
        }
        DiameterIdentity destRealm = new DiameterIdentity(smscPropertiesManagement.getDiameterDestRealm());
        RoClientSessionActivity activity = this.roProvider.createRoClientSessionActivity(destHost, destRealm);
        ActivityContextInterface roACI = acif.getActivityContextInterface(activity);
        roACI.attach(getSbbContext().getSbbLocalObject());
        RoCreditControlRequest ccr = activity.createRoCreditControlRequest(CcRequestType.EVENT_REQUEST);
        // ccr.setDestinationRealm(destRealm);
        // ccr.setAuthApplicationId(APPLICATION_ID_OF_THE_DIAMETER_CREDIT_CONTROL_APPLICATION);
        ccr.setServiceContextId(SERVICE_CONTEXT_ID_SMSC);
        ccr.setCcRequestNumber(0);
        // ((SipUri)fromHeader.getAddress().getURI()).getUser();
        if (smscPropertiesManagement.getDiameterUserName() != null && !smscPropertiesManagement.getDiameterUserName().equals("")) {
            ccr.setUserName(smscPropertiesManagement.getDiameterUserName());
        }
        // This field contains the state associated to the CTF
        // do not know how to use it
        // a monotonically increasing value that is advanced whenever a
        // Diameter
        // entity restarts with loss of previous state, for example upon
        // reboot
        // ccr.setOriginStateId(smscRebootStep);
        // do not know if we need it
        ccr.setEventTimestamp(Calendar.getInstance().getTime());
        SubscriptionIdAvp subId = avpFactory.createSubscriptionId(SubscriptionIdType.END_USER_E164, sourceAddress);
        ccr.setSubscriptionId(subId);
        ccr.setRequestedAction(RequestedActionType.DIRECT_DEBITING);
        // ccr.setMultipleServicesIndicator(MultipleServicesIndicatorType.MULTIPLE_SERVICES_NOT_SUPPORTED);
        // requested units
        int messageCount = 1;
        int serviceIdentifier = 1;
        MultipleServicesCreditControlAvp multipleServicesCreditControl = avpFactory.createMultipleServicesCreditControl();
        RequestedServiceUnitAvp requestedServiceUnit = avpFactory.createRequestedServiceUnit();
        requestedServiceUnit.setCreditControlServiceSpecificUnits(messageCount);
        multipleServicesCreditControl.setRequestedServiceUnit(requestedServiceUnit);
        multipleServicesCreditControl.setServiceIdentifier(serviceIdentifier);
        ccr.setMultipleServicesCreditControl(multipleServicesCreditControl);
        // RequestedServiceUnitAvp RSU =
        // avpFactory.createRequestedServiceUnit();
        // RSU.setCreditControlTime(_FIRST_CHARGE_TIME);
        // ccr.setRequestedServiceUnit(RSU);
        // ServiceInformation - SMS info 2000
        ArrayList<DiameterAvp> smsInfoAvpLst = new ArrayList<DiameterAvp>();
        int vendorID = 10415;
        // Originator-SCCP-Address 2008
        if (originatorSccpAddress != null) {
            byte[] originatorSccpAddressAddrPartByteArr = originatorSccpAddress.getBytes(utf8Charset);
            byte[] originatorSccpAddressByteArr = new byte[2 + originatorSccpAddressAddrPartByteArr.length];
            originatorSccpAddressByteArr[1] = 8;
            System.arraycopy(originatorSccpAddressAddrPartByteArr, 0, originatorSccpAddressByteArr, 2, originatorSccpAddressAddrPartByteArr.length);
            DiameterAvp avpOriginatorSccpAddress = avpFactory.getBaseFactory().createAvp(vendorID, 2008, originatorSccpAddressByteArr);
            smsInfoAvpLst.add(avpOriginatorSccpAddress);
        }
        // SMSC-Address 2017
        if (origMoServiceCentreAddressDA != null) {
            byte[] origMoServiceCentreAddressDAPartByteArr = origMoServiceCentreAddressDA.getBytes(utf8Charset);
            byte[] origMoServiceCentreAddressDAByteArr = new byte[2 + origMoServiceCentreAddressDAPartByteArr.length];
            origMoServiceCentreAddressDAByteArr[1] = 8;
            System.arraycopy(origMoServiceCentreAddressDAPartByteArr, 0, origMoServiceCentreAddressDAByteArr, 2, origMoServiceCentreAddressDAPartByteArr.length);
            DiameterAvp avpOrigMoServiceCentreAddressDA = avpFactory.getBaseFactory().createAvp(vendorID, 2017, origMoServiceCentreAddressDAByteArr);
            smsInfoAvpLst.add(avpOrigMoServiceCentreAddressDA);
        }
        // Data-Coding-Scheme 2001
        DiameterAvp avpDataCodingScheme = avpFactory.getBaseFactory().createAvp(vendorID, 2001, dataCodingScheme);
        smsInfoAvpLst.add(avpDataCodingScheme);
        // SM-Message-Type 2007
        DiameterAvp avpSmMessageType = avpFactory.getBaseFactory().createAvp(vendorID, 2007, SmMessageTypeEnum.SUBMISSION.getValue());
        smsInfoAvpLst.add(avpSmMessageType);
        // Originator-Interface 2009
        ArrayList<DiameterAvp> originatorInterfaceAvpLst = new ArrayList<DiameterAvp>();
        DiameterAvp avpInterfaceId = avpFactory.getBaseFactory().createAvp(vendorID, 2003, interfaceId);
        originatorInterfaceAvpLst.add(avpInterfaceId);
        if (interfaceText != null) {
            DiameterAvp avpInterfaceText = avpFactory.getBaseFactory().createAvp(vendorID, 2005, interfaceText);
            originatorInterfaceAvpLst.add(avpInterfaceText);
        }
        DiameterAvp[] originatorInterfaceAvpArr = new DiameterAvp[originatorInterfaceAvpLst.size()];
        originatorInterfaceAvpLst.toArray(originatorInterfaceAvpArr);
        DiameterAvp avpOriginatorInterface = avpFactory.getBaseFactory().createAvp(vendorID, 2009, originatorInterfaceAvpArr);
        smsInfoAvpLst.add(avpOriginatorInterface);
        // Recipient-Address 1201
        ArrayList<DiameterAvp> recipientAddressAvpLst = new ArrayList<DiameterAvp>();
        DiameterAvp avpAddressType;
        if (destTon == 1)
            avpAddressType = avpFactory.getBaseFactory().createAvp(vendorID, 899, AddressTypeEnum.Msisdn.getValue());
        else
            avpAddressType = avpFactory.getBaseFactory().createAvp(vendorID, 899, AddressTypeEnum.Others.getValue());
        recipientAddressAvpLst.add(avpAddressType);
        DiameterAvp avpAddressData = avpFactory.getBaseFactory().createAvp(vendorID, 897, recipientAddress);
        recipientAddressAvpLst.add(avpAddressData);
        DiameterAvp[] recipientAddressAvpArr = new DiameterAvp[recipientAddressAvpLst.size()];
        recipientAddressAvpLst.toArray(recipientAddressAvpArr);
        DiameterAvp avpRecipientAddress = avpFactory.getBaseFactory().createAvp(vendorID, 1201, recipientAddressAvpArr);
        // Recipient-Info 2026
        ArrayList<DiameterAvp> recipientInfoAvpLst = new ArrayList<DiameterAvp>();
        recipientInfoAvpLst.add(avpRecipientAddress);
        DiameterAvp[] recipientInfoAvpArr = new DiameterAvp[recipientInfoAvpLst.size()];
        recipientInfoAvpLst.toArray(recipientInfoAvpArr);
        DiameterAvp avpRecipientInfo = avpFactory.getBaseFactory().createAvp(vendorID, 2026, recipientInfoAvpArr);
        smsInfoAvpLst.add(avpRecipientInfo);
        // Originator-Received-Address 2027
        ArrayList<DiameterAvp> originatorReceivedAddressAvpLst = new ArrayList<DiameterAvp>();
        if (sourceTon == 1)
            avpAddressType = avpFactory.getBaseFactory().createAvp(vendorID, 899, AddressTypeEnum.Msisdn.getValue());
        else
            avpAddressType = avpFactory.getBaseFactory().createAvp(vendorID, 899, AddressTypeEnum.Others.getValue());
        originatorReceivedAddressAvpLst.add(avpAddressType);
        avpAddressData = avpFactory.getBaseFactory().createAvp(vendorID, 897, sourceAddress);
        originatorReceivedAddressAvpLst.add(avpAddressData);
        DiameterAvp[] originatorReceivedAddressAvpArr = new DiameterAvp[originatorReceivedAddressAvpLst.size()];
        originatorReceivedAddressAvpLst.toArray(originatorReceivedAddressAvpArr);
        DiameterAvp avpOriginatorReceivedAddress = avpFactory.getBaseFactory().createAvp(vendorID, 2027, originatorReceivedAddressAvpArr);
        smsInfoAvpLst.add(avpOriginatorReceivedAddress);
        // final assembling
        DiameterAvp[] smsInfoAvpArr = new DiameterAvp[smsInfoAvpLst.size()];
        smsInfoAvpLst.toArray(smsInfoAvpArr);
        DiameterAvp[] smsInfo = new DiameterAvp[1];
        smsInfo[0] = avpFactory.getBaseFactory().createAvp(vendorID, 2000, smsInfoAvpArr);
        ServiceInformation si = avpFactory.createServiceInformation();
        si.setExtensionAvps(smsInfo);
        ccr.setServiceInformation(si);
        activity.sendEventRoCreditControlRequest(ccr);
        if (logger.isFineEnabled()) {
            logger.fine("Sent INITIAL CCR: " + ccr);
        }
        // set new timer for the case we will not get CCA in time
        timerFacility.setTimer(roACI, null, System.currentTimeMillis() + (CCR_TIMEOUT * 1000), defaultTimerOptions);
    } catch (Exception e1) {
        logger.severe("setupChargingRequestInterface(): error while sending RoCreditControlRequest: " + e1.getMessage(), e1);
        generateCDR(sms, CdrGenerator.CDR_SUBMIT_FAILED_CHARGING, e1.getMessage(), false, true);
    }
}
Also used : MultipleServicesCreditControlAvp(net.java.slee.resource.diameter.cca.events.avp.MultipleServicesCreditControlAvp) ActivityContextInterface(javax.slee.ActivityContextInterface) ArrayList(java.util.ArrayList) RoClientSessionActivity(net.java.slee.resource.diameter.ro.RoClientSessionActivity) RoCreditControlRequest(net.java.slee.resource.diameter.ro.events.RoCreditControlRequest) SubscriptionIdAvp(net.java.slee.resource.diameter.cca.events.avp.SubscriptionIdAvp) SmscProcessingException(org.mobicents.smsc.library.SmscProcessingException) CreateException(javax.slee.CreateException) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) ServiceInformation(net.java.slee.resource.diameter.ro.events.avp.ServiceInformation) DiameterIdentity(net.java.slee.resource.diameter.base.events.avp.DiameterIdentity) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) RequestedServiceUnitAvp(net.java.slee.resource.diameter.cca.events.avp.RequestedServiceUnitAvp)

Example 14 with DiameterIdentity

use of net.java.slee.resource.diameter.base.events.avp.DiameterIdentity in project jain-slee.diameter by RestComm.

the class DiameterS6aResourceAdaptor method getConnectedPeers.

public DiameterIdentity[] getConnectedPeers() {
    if (this.stack != null) {
        try {
            // Get the list of peers from the stack
            List<Peer> peers = stack.unwrap(PeerTable.class).getPeerTable();
            DiameterIdentity[] result = new DiameterIdentity[peers.size()];
            int i = 0;
            // Get each peer from the list and make a DiameterIdentity
            for (Peer peer : peers) {
                DiameterIdentity identity = new DiameterIdentity(peer.getUri().toString());
                result[i++] = identity;
            }
            return result;
        } catch (Exception e) {
            tracer.severe("Failure getting peer list.", e);
        }
    }
    return new DiameterIdentity[0];
}
Also used : DiameterIdentity(net.java.slee.resource.diameter.base.events.avp.DiameterIdentity) Peer(org.jdiameter.api.Peer) PeerTable(org.jdiameter.api.PeerTable) SleeEndpoint(javax.slee.resource.SleeEndpoint) AvpDataException(org.jdiameter.api.AvpDataException) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) OperationNotSupportedException(javax.naming.OperationNotSupportedException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException)

Example 15 with DiameterIdentity

use of net.java.slee.resource.diameter.base.events.avp.DiameterIdentity in project jain-slee.diameter by RestComm.

the class DiameterRoResourceAdaptor method getConnectedPeers.

public DiameterIdentity[] getConnectedPeers() {
    if (this.stack != null) {
        try {
            // Get the list of peers from the stack
            List<Peer> peers = stack.unwrap(PeerTable.class).getPeerTable();
            DiameterIdentity[] result = new DiameterIdentity[peers.size()];
            int i = 0;
            // Get each peer from the list and make a DiameterIdentity
            for (Peer peer : peers) {
                DiameterIdentity identity = new DiameterIdentity(peer.getUri().toString());
                result[i++] = identity;
            }
            return result;
        } catch (Exception e) {
            tracer.severe("Failure getting peer list.", e);
        }
    }
    return new DiameterIdentity[0];
}
Also used : DiameterIdentity(net.java.slee.resource.diameter.base.events.avp.DiameterIdentity) Peer(org.jdiameter.api.Peer) PeerTable(org.jdiameter.api.PeerTable) SleeEndpoint(javax.slee.resource.SleeEndpoint) AvpDataException(org.jdiameter.api.AvpDataException) IOException(java.io.IOException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) OperationNotSupportedException(javax.naming.OperationNotSupportedException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException)

Aggregations

DiameterIdentity (net.java.slee.resource.diameter.base.events.avp.DiameterIdentity)29 ShClientActivity (net.java.slee.resource.diameter.sh.client.ShClientActivity)17 UserIdentityAvp (net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)17 UserDataRequest (net.java.slee.resource.diameter.sh.events.UserDataRequest)10 InvalidConfigurationException (javax.slee.resource.InvalidConfigurationException)9 SleeEndpoint (javax.slee.resource.SleeEndpoint)9 CreateActivityException (net.java.slee.resource.diameter.base.CreateActivityException)9 AvpDataException (org.jdiameter.api.AvpDataException)9 Peer (org.jdiameter.api.Peer)9 PeerTable (org.jdiameter.api.PeerTable)9 OperationNotSupportedException (javax.naming.OperationNotSupportedException)8 IOException (java.io.IOException)5 SubscribeNotificationsRequest (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest)5 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)4 InternalException (org.jdiameter.api.InternalException)4 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)2 ProfileUpdateRequest (net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest)2 ArrayList (java.util.ArrayList)1 ActivityContextInterface (javax.slee.ActivityContextInterface)1 CreateException (javax.slee.CreateException)1