Search in sources :

Example 6 with ProfileUpdateAnswer

use of net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer in project jain-slee.diameter by RestComm.

the class ShServerFactoriesTest method isProxiableCopiedPUA.

@Test
public void isProxiableCopiedPUA() throws Exception {
    ProfileUpdateRequest pur = shClientFactory.createProfileUpdateRequest();
    ProfileUpdateAnswer pua = shServerFactory.createProfileUpdateAnswer(pur);
    assertEquals("The 'P' bit is not copied from request in Profile-Update-Answer, it should. [RFC3588/6.2]", pur.getHeader().isProxiable(), pua.getHeader().isProxiable());
    // Reverse 'P' bit ...
    ((DiameterMessageImpl) pur).getGenericData().setProxiable(!pur.getHeader().isProxiable());
    assertTrue("The 'P' bit was not modified in Profile-Update-Request, it should.", pur.getHeader().isProxiable() != pua.getHeader().isProxiable());
    pua = shServerFactory.createProfileUpdateAnswer(pur);
    assertEquals("The 'P' bit is not copied from request in Profile-Update-Answer, it should. [RFC3588/6.2]", pur.getHeader().isProxiable(), pua.getHeader().isProxiable());
}
Also used : ProfileUpdateAnswer(net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer) ProfileUpdateRequest(net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 7 with ProfileUpdateAnswer

use of net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer in project jain-slee.diameter by RestComm.

the class ShServerActivityImpl method sendProfileUpdateAnswer.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.sh.server.ShServerActivity#sendProfileUpdateAnswer(net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer)
   */
public void sendProfileUpdateAnswer(ProfileUpdateAnswer message) throws IOException {
    try {
        DiameterShMessageImpl msg = (DiameterShMessageImpl) message;
        fetchSessionData(msg, false);
        this.serverSession.sendProfileUpdateAnswer(new ProfileUpdateAnswerImpl((Answer) msg.getGenericData()));
        clean(msg);
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : Answer(org.jdiameter.api.Answer) SubscribeNotificationsAnswer(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsAnswer) ProfileUpdateAnswer(net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer) UserDataAnswer(net.java.slee.resource.diameter.sh.events.UserDataAnswer) DiameterShMessageImpl(org.mobicents.slee.resource.diameter.sh.events.DiameterShMessageImpl) ProfileUpdateAnswerImpl(org.jdiameter.common.impl.app.sh.ProfileUpdateAnswerImpl) IOException(java.io.IOException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException)

Example 8 with ProfileUpdateAnswer

use of net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer in project jain-slee.diameter by RestComm.

the class ShServerActivityImpl method createProfileUpdateAnswer.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.sh.server.ShServerActivity#createProfileUpdateAnswer()
   */
public ProfileUpdateAnswer createProfileUpdateAnswer() {
    // Fetch the session stored request
    ProfileUpdateRequest req = (ProfileUpdateRequest) getSessionMessage(ProfileUpdateRequest.commandCode);
    ProfileUpdateAnswer answer = null;
    if (req != null) {
        // Create answer from it
        answer = this.messageFactory.createProfileUpdateAnswer(req);
        // Add any extra session data
        addSessionData(answer);
    // Store request data FIXME: Commented by Alex. Is this needed?
    // ((DiameterShMessageImpl)answer).setData(req);
    }
    return answer;
}
Also used : ProfileUpdateAnswer(net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer) ProfileUpdateRequest(net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest)

Example 9 with ProfileUpdateAnswer

use of net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer in project jain-slee.diameter by RestComm.

the class ShServerSubscriptionActivityImpl method sendProfileUpdateAnswer.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.sh.server.ShServerSubscriptionActivity#sendProfileUpdateAnswer(net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer)
   */
public void sendProfileUpdateAnswer(ProfileUpdateAnswer message) throws IOException {
    try {
        DiameterShMessageImpl msg = (DiameterShMessageImpl) message;
        fetchSessionData(msg, false);
        this.serverSession.sendProfileUpdateAnswer(new ProfileUpdateAnswerImpl((Answer) msg.getGenericData()));
        clean(msg);
    } 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.", e);
        }
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : Answer(org.jdiameter.api.Answer) SubscribeNotificationsAnswer(net.java.slee.resource.diameter.sh.events.SubscribeNotificationsAnswer) ProfileUpdateAnswer(net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer) UserDataAnswer(net.java.slee.resource.diameter.sh.events.UserDataAnswer) DiameterShMessageImpl(org.mobicents.slee.resource.diameter.sh.events.DiameterShMessageImpl) ProfileUpdateAnswerImpl(org.jdiameter.common.impl.app.sh.ProfileUpdateAnswerImpl) IOException(java.io.IOException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException)

Example 10 with ProfileUpdateAnswer

use of net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer in project jain-slee.diameter by RestComm.

the class ShServerFactoriesTest method testMessageFactoryApplicationIdChangePUA.

@Test
public void testMessageFactoryApplicationIdChangePUA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((ShServerMessageFactoryImpl) shServerFactory).getApplicationId();
    boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isVendor = originalAppId.getVendorId() != 0L;
    assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
    System.out.println("Default VENDOR-ID for Sh is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    ProfileUpdateAnswer originalPUA = shServerFactory.createProfileUpdateAnswer(shClientFactory.createProfileUpdateRequest());
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalPUA);
    // now we switch..
    originalPUA = null;
    isVendor = !isVendor;
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    ProfileUpdateAnswer changedPUA = shServerFactory.createProfileUpdateAnswer(shClientFactory.createProfileUpdateRequest());
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedPUA);
    // revert back to default
    ((ShServerMessageFactoryImpl) shServerFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : ProfileUpdateAnswer(net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer) ApplicationId(org.jdiameter.api.ApplicationId) ShServerMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

ProfileUpdateAnswer (net.java.slee.resource.diameter.sh.events.ProfileUpdateAnswer)15 Test (org.junit.Test)9 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)9 ProfileUpdateRequest (net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest)7 DiameterShMessageImpl (org.mobicents.slee.resource.diameter.sh.events.DiameterShMessageImpl)4 IOException (java.io.IOException)2 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)2 SubscribeNotificationsAnswer (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsAnswer)2 UserDataAnswer (net.java.slee.resource.diameter.sh.events.UserDataAnswer)2 Answer (org.jdiameter.api.Answer)2 ApplicationId (org.jdiameter.api.ApplicationId)2 ProfileUpdateAnswerImpl (org.jdiameter.common.impl.app.sh.ProfileUpdateAnswerImpl)2 ShServerMessageFactoryImpl (org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl)2 UserIdentityAvp (net.java.slee.resource.diameter.sh.events.avp.UserIdentityAvp)1