|
|
@@ -63,12 +63,12 @@ public class SIPmodel implements SipListenerExt |
|
|
|
Boolean werdeAngerufen; |
|
|
|
private int countWerdeAngerufen; |
|
|
|
|
|
|
|
public long cSequenz = 1; |
|
|
|
private long cSequenz = 1; |
|
|
|
private String proxyTag; |
|
|
|
private String myTag = String.valueOf(new Random().nextInt()); |
|
|
|
private int branch = Integer.valueOf(hashCode()); |
|
|
|
public Address contactAddress; |
|
|
|
public ContactHeader contactHeader; |
|
|
|
private Address contactAddress; |
|
|
|
private ContactHeader contactHeader; |
|
|
|
|
|
|
|
public SIPmodel(Hauptfenster view) //Konstruktor für eigene Daten |
|
|
|
{ |
|
|
@@ -96,7 +96,6 @@ public class SIPmodel implements SipListenerExt |
|
|
|
this.listeningPoint = this.sipStack.createListeningPoint(this.myIPAddress, this.myPort, this.protocolTyp); |
|
|
|
this.sipProvider = this.sipStack.createSipProvider(this.listeningPoint); |
|
|
|
this.sipProvider.addSipListener(this); |
|
|
|
//this.contactAddress = this.addressFactory.createAddress("sip:129@" + this.myIPAddress + ":" + this.myPort); //+ ":" + this.myPort |
|
|
|
this.contactAddress = this.addressFactory.createAddress("sip:" + myName + "@" + this.myIPAddress + ":" + this.myPort); |
|
|
|
this.contactHeader = this.headerFactory.createContactHeader(contactAddress); |
|
|
|
} |
|
|
@@ -221,51 +220,17 @@ public class SIPmodel implements SipListenerExt |
|
|
|
@Override |
|
|
|
public void processResponse(ResponseEvent responseEvent) |
|
|
|
{ |
|
|
|
System.out.println("---Response---"); |
|
|
|
//System.out.println(responseEvent.getResponse()); |
|
|
|
|
|
|
|
if (responseEvent.getResponse().getStatusCode() == Response.UNAUTHORIZED) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
Address addresstob = this.addressFactory.createAddress("sip:" + myName + "@" + proxyAddress); |
|
|
|
ToHeader temp = (ToHeader) responseEvent.getResponse().getHeader("To"); |
|
|
|
|
|
|
|
ToHeader to = this.headerFactory.createToHeader(addresstob, temp.getTag()); // Integer.toString(myTag) address + myTag |
|
|
|
URI requestURI = addresstob.getURI(); |
|
|
|
CallIdHeader callId = (CallIdHeader) responseEvent.getResponse().getHeader("Call-ID"); |
|
|
|
FromHeader from = this.headerFactory.createFromHeader(addresstob, this.myTag); //this.contactAddress |
|
|
|
WWWAuthenticateHeader wwwauth = (WWWAuthenticateHeader) responseEvent.getResponse().getHeader("WWW-Authenticate"); |
|
|
|
|
|
|
|
//wird bei AuthorizationHeader wirklich alles benötigt? war glaub nur mal Test -> testen!! |
|
|
|
AuthorizationHeader auth = this.headerFactory.createAuthorizationHeader("Digest");//was kommt in den string |
|
|
|
auth.setRealm(wwwauth.getRealm()); |
|
|
|
auth.setNonce(wwwauth.getNonce()); |
|
|
|
//Address addresstest = this.addressFactory.createAddress("sip:" + myName + "@192.168.100.11"); //vielleicht passwort setzen "sip:"+myName+":\"\"@192.168.100.11" |
|
|
|
Address addresstest = this.addressFactory.createAddress("sip:" + myName + "@" + proxyAddress); |
|
|
|
auth.setURI(addresstest.getURI()); |
|
|
|
auth.setUsername(myName); |
|
|
|
|
|
|
|
ArrayList via = new ArrayList(); //Via needs a List as input |
|
|
|
ViaHeader viaheader = this.headerFactory.createViaHeader(this.myIPAddress, this.myPort, "UDP", String.valueOf(branch + 2));// String.valueOf(hashCode())string branch |
|
|
|
via.add(viaheader); |
|
|
|
|
|
|
|
CSeqHeader cSeq = this.headerFactory.createCSeqHeader(2L, "REGISTER"); |
|
|
|
MaxForwardsHeader maxForwards = this.headerFactory.createMaxForwardsHeader(70); |
|
|
|
AllowHeader allow = this.headerFactory.createAllowHeader("NOTIFY,INVITE,ACK,CANCEL,BYE,REFER,INFO,OPTIONS,MESSAGE"); |
|
|
|
ExpiresHeader expire = this.headerFactory.createExpiresHeader(3600); //int value |
|
|
|
|
|
|
|
//Zusätzliche Register Header nach Unauthorzied |
|
|
|
//Create Request Header |
|
|
|
Request request = this.messageFactory.createRequest(requestURI, "REGISTER", callId, cSeq, from, to, via, maxForwards); |
|
|
|
request.addHeader(contactHeader); |
|
|
|
request.addHeader(allow); |
|
|
|
request.addHeader(expire); |
|
|
|
request.addHeader(auth); |
|
|
|
this.sipProvider.sendRequest(request); |
|
|
|
cSequenz += 1L; |
|
|
|
branch += 10; |
|
|
|
SIPUnauthReq req2 = new SIPUnauthReq(myName, proxyAddress, myTag, myIPAddress, branch, cSequenz, myPort, contactHeader, addressFactory, headerFactory, responseEvent, messageFactory); |
|
|
|
sipProvider.sendRequest(req2.getUnauthReq()); |
|
|
|
view.getTxtArea().append("Erfolgreich registriert\n"); |
|
|
|
} |
|
|
|
catch (ParseException | SipException | InvalidArgumentException ex) |
|
|
|
catch (SipException ex) |
|
|
|
{ |
|
|
|
lg.getLogger(SIPmodel.class.getName()).log(Level.SEVERE, null, ex); |
|
|
|
} |
|
|
@@ -288,7 +253,6 @@ public class SIPmodel implements SipListenerExt |
|
|
|
|
|
|
|
public Response create180Ringing(RequestEvent requestEvent) throws ParseException, SipException |
|
|
|
{ |
|
|
|
|
|
|
|
Response responsering = this.messageFactory.createResponse(180, requestEvent.getRequest()); |
|
|
|
responsering.addHeader((ViaHeader) requestEvent.getRequest().getHeader("Via")); |
|
|
|
responsering.addHeader((FromHeader) requestEvent.getRequest().getHeader("From")); |
|
|
@@ -326,14 +290,12 @@ public class SIPmodel implements SipListenerExt |
|
|
|
view.getTxtArea().append("Trying geschickt\n"); |
|
|
|
lg.info("Trying ist raus"); |
|
|
|
|
|
|
|
//Ringing Message to Server (Responste Ringing)From tag: proxyTag, To Tag, persönlicher Tag |
|
|
|
//Ringing Header erzeugen und abschicken From tag: proxyTag; To Tag: persönlicher Tag |
|
|
|
SIP180Ringing tempRinging = new SIP180Ringing(requestEvent, myTag, proxyTag, contactHeader, headerFactory); |
|
|
|
sipProvider.sendResponse(tempRinging.getResponseRing()); |
|
|
|
view.getTxtArea().append("Ringing geschickt\n"); |
|
|
|
|
|
|
|
//Jetzt kommt 200 Ok SIP Header + SDP (SIP/SDP) |
|
|
|
//Sdp Header erstellen nächster Schritt |
|
|
|
|
|
|
|
//200OK Header mit Session Description erstellen |
|
|
|
invite = false; |
|
|
|
SIP200Ok respcall = new SIP200Ok(messageFactory, requestEvent, contactHeader, headerFactory); |
|
|
|
SIPSessionDescription sdp = new SIPSessionDescription(myName, myIPAddress, requestEvent, false); |
|
|
@@ -346,7 +308,6 @@ public class SIPmodel implements SipListenerExt |
|
|
|
catch (SipException ex) |
|
|
|
{ |
|
|
|
Logger.getLogger(SIPmodel.class.getName()).log(Level.SEVERE, null, ex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |