public void processResponse(ResponseEvent responseReceivedEvent) { // Log.info("Registering response...." + sipCallId); Response response = (Response) responseReceivedEvent.getResponse(); int statusCode = response.getStatusCode(); String method = ((CSeqHeader) response.getHeader(CSeqHeader.NAME)).getMethod(); Log.debug("Got response " + response); if (statusCode == Response.OK) { isRegistered = true; Log.info( "Voice bridge successfully registered with " + registrar + " for " + proxyCredentials.getXmppUserName()); PluginImpl.sipRegisterStatus = "Registered ok with " + proxyCredentials.getHost(); sipServerCallback.removeSipListener(sipCallId); } else if (statusCode == Response.UNAUTHORIZED || statusCode == Response.PROXY_AUTHENTICATION_REQUIRED) { if (method.equals(Request.REGISTER)) { CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME); if (cseq.getSequenceNumber() < 2) { ClientTransaction regTrans = SipService.handleChallenge( response, responseReceivedEvent.getClientTransaction(), proxyCredentials); if (regTrans != null) { try { regTrans.sendRequest(); } catch (Exception e) { Log.info("Registration failed, cannot send transaction " + e); PluginImpl.sipRegisterStatus = "Registration error " + e.toString(); } } else { Log.info("Registration failed, cannot create transaction"); PluginImpl.sipRegisterStatus = "Registration cannot create transaction"; } } else { Log.info("Registration failed " + responseReceivedEvent); PluginImpl.sipRegisterStatus = "Registration failed"; } } } else { Log.info("Unrecognized response: " + response); } }
private ContactHeader getRegistrationContactHeader() throws IOException { if (contactHeader != null) { return contactHeader; } try { SipURI contactURI = (SipURI) addressFactory.createURI( "sip:" + proxyCredentials.getUserName() + "@" + proxyCredentials.getHost()); contactURI.setTransportParam(sipProvider.getListeningPoint().getTransport()); contactURI.setPort(sipProvider.getListeningPoint().getPort()); Address contactAddress = addressFactory.createAddress(contactURI); contactAddress.setDisplayName(proxyCredentials.getUserDisplay()); contactHeader = headerFactory.createContactHeader(contactAddress); return contactHeader; } catch (ParseException e) { throw new IOException( "A ParseException occurred while creating From Header! " + " " + e.getMessage()); } }