private SipResponse processRegisterRequest ( final SipRequest request ) { final SipURI requestURI = ( SipURI ) request . getRequestUri ( ) ; final Buffer domain = requestURI . getHost ( ) ; final SipURI aor = getAOR ( request ) ; // the aor is not allowed to register under this domain // generate a 404 according to specfication if ( ! validateDomain ( domain , aor ) ) { return request . createResponse ( 404 ) ; } final Binding . Builder builder = Binding . with ( ) ; builder . aor ( aor ) ; builder . callId ( request . getCallIDHeader ( ) ) ; builder . expires ( getExpires ( request ) ) ; builder . cseq ( request . getCSeqHeader ( ) ) ; // NOTE: this is also cheating. There may be multiple contacts // and they must all get processed but whatever... builder . contact ( getContactURI ( request ) ) ; final Binding binding = builder . build ( ) ; final List < Binding > currentBindings = this . locationService . updateBindings ( binding ) ; final SipResponse response = request . createResponse ( 200 ) ; currentBindings . forEach ( b -> { final SipURI contactURI = b . getContact ( ) ; contactURI . setParameter ( "expires" , b . getExpires ( ) ) ; final ContactHeader contact = ContactHeader . with ( contactURI ) . build ( ) ; response . addHeader ( contact ) ; } ) ; return response ; }
Section 10 . 3 in RFC3261 outlines how to process a register request . For the purpose of this little exercise we are skipping many steps just to keep things simple .