- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在我的java应用程序中构建一个电话调用器。为此,我使用了 JAIN-SIP 库。第一次 INVITE 后,系统需要代理身份验证。第二个邀请是在“AuthenticationHelperImpl.class”的帮助下构建的: https://gitorious.org/0xdroid/external_nist-sip/source/1e0f37693341071f316852c8e05a08deef2b7fc4:java/gov/nist/javax/sip/clientauthutils/AuthenticationHelperImpl.java#L311 ,包括代理身份验证 header 和类似的内容:
INVITE sip:+11111111111@fpbx.de;maddr=fpbx.de SIP/2.0
Call-ID: 1c609509a43b721ab11c396c1e6ea9e7@192.168.17.107
CSeq: 2 INVITE
From: "77735hk6iu" <sip:77735hk6iu@fpbx.de>
To: "+111111111111111" <sip:+11111111111@fpbx.de>
Via: SIP/2.0/UDP 192.168.17.107:34567;rport;branch=z9hG4bK-383337-5bc4fd6b7a616843fce9eaa243bcb10e
Max-Forwards: 70
Contact: <sip:77735hk6iu@192.168.17.107:5060>
Content-Type: application/sdp
Proxy-Authorization: Digest username="77735hk6iu",realm="fpbx.de",nonce="VLaIxVS2h5muPS30F2zLdXHjup6ELyen",uri="sip:+111111111111@fpbx.de:5060;maddr=fpbx.de",response="47ea578c6b01c99fd3ed2b41c60983df"
Content-Length: 61
v=0
o=- 130565705777141827 1 IN IP4 192.168.17.107
s=call
此后,我首先收到代码 100 消息(“您的调用对我们非常重要”),然后收到代码 408 消息(“请求超时”)。
我做了什么来改善这种情况:
尝试了不同的电话号码格式:004930208488480,04930208488480, 049, 0049, sdfhajfkhsk。对于所有这些数字我在消息上变成相同的组合。
尝试在请求 URI 中使用端口
尝试从请求 URI 中删除 maddr。
尝试使用代码设置填充消息正文。
通过 header 设置和删除 rport
如果你现在我做错了什么,请帮助我。预先感谢您。
最佳答案
我想,也许你的代理授权 header 是错误的。也许你算错了。我想分享我的决心。
authUser 是您的电话号码。 (例如:77735hk6iu)authPass 是您的用户的密码。msg 是您的邀请请求。( header !)
AccountManagerImpl accountManagerImp = new AccountManagerImpl(authUser, AuthPass);
AuthenticationHelperImpl authenticationHelperImpl = new AuthenticationHelperImpl(accountManagerImp);
try {
this.authentication = authenticationHelperImpl.handleChallenge(msg, (SIPClientTransaction)trans);
AuthenticationHelperImple.java 类:
public AuthorizationHeader handleChallenge(Response challenge, ClientTransaction challengedTransaction) throws SipException {
SIPRequest challengedRequest = ((SIPRequest) challengedTransaction.getRequest());
ListIterator authHeaders = null;
if (challenge.getStatusCode() == Response.UNAUTHORIZED) {
authHeaders = challenge.getHeaders(WWWAuthenticateHeader.NAME);
}
else {
if (challenge.getStatusCode() == Response.PROXY_AUTHENTICATION_REQUIRED) {
authHeaders = challenge.getHeaders(ProxyAuthenticateHeader.NAME);
}
else {
throw new IllegalArgumentException("Unexpected status code ");
}
}
if (authHeaders == null) {
throw new IllegalArgumentException("Could not find WWWAuthenticate or ProxyAuthenticate headers");
}
WWWAuthenticateHeader authHeader = null;
while (authHeaders.hasNext()) {
authHeader = (WWWAuthenticateHeader) authHeaders.next();
String realm = authHeader.getRealm();
this.uri = challengedRequest.getRequestURI();
this.requestMethod = challengedRequest.getMethod();
this.requestBody = (challengedRequest.getContent() == null) ? "" : new String(challengedRequest.getRawContent());
if (this.accountManager instanceof SecureAccountManager) {
UserCredentialHash credHash = ((SecureAccountManager) this.accountManager).getCredentialHash(challengedTransaction,
realm);
if (credHash == null) {
logger.logDebug("Could not find creds");
throw new SipException("Cannot find user creds for the given user name and realm");
}
this.authorizationHeader = this.getAuthorization(requestMethod, uri.toString(), requestBody, authHeader, credHash);
}
else {
UserCredentials userCreds = ((AccountManager) this.accountManager).getCredentials(challengedTransaction, realm);
if (userCreds == null) {
throw new SipException("Cannot find user creds for the given user name and realm");
}
// sipDomain = userCreds.getSipDomain();
// we haven't yet authenticated this realm since we were
// started.
this.authorizationHeader = this.getAuthorization(requestMethod, uri.toString(), requestBody, authHeader, userCreds);
}
}
return this.authorizationHeader;
}
获取授权函数:
public AuthorizationHeader getAuthorization(String method,
String uri,
String requestBody,
WWWAuthenticateHeader authHeader,
UserCredentials userCredentials) throws SecurityException {
String response = null;
String qopList = authHeader.getQop();
String qop = (qopList != null) ? "auth" : null;
String nc_value = "00000001";
String cnonce = "xyz";
try {
response = MessageDigestAlgorithm.calculateResponse(authHeader.getAlgorithm(),
userCredentials.getUserName(), authHeader.getRealm(),userCredentials.getPassword(), authHeader.getNonce(), nc_value, // JvB added
cnonce, // JvB added
method, uri, requestBody, qop,logger);
}
catch (NullPointerException exc) {
throw new SecurityException("The received authenticate header was malformatted: " + exc.getMessage());
}
AuthorizationHeader authorization = null;
try {
if (authHeader instanceof ProxyAuthenticateHeader) {
if (this.headerFactory != null) {
authorization = headerFactory.createProxyAuthorizationHeader(authHeader.getScheme());
}
else {
authorization = new ProxyAuthorization();
authorization.setScheme(authHeader.getScheme());
}
}
else {
if (this.headerFactory != null) {
authorization = headerFactory.createAuthorizationHeader(authHeader.getScheme());
}
else {
authorization = new Authorization();
authorization.setScheme(authHeader.getScheme());
}
}
authorization.setUsername(userCredentials.getUserName());
authorization.setRealm(authHeader.getRealm());
authorization.setNonce(authHeader.getNonce());
authorization.setParameter("uri", uri);
authorization.setResponse(response);
if (authHeader.getAlgorithm() != null) {
authorization.setAlgorithm(authHeader.getAlgorithm());
}
if (authHeader.getOpaque() != null) {
authorization.setOpaque(authHeader.getOpaque());
}
// jvb added
if (qop != null) {
authorization.setQop(qop);
authorization.setCNonce(cnonce);
authorization.setNonceCount(Integer.parseInt(nc_value));
}
authorization.setResponse(response);
} catch (ParseException ex) {
throw new RuntimeException("Failed to create an authorization header!");
}
return authorization;
}
最后,您的 this.authentication 变量是 ProxyAuthorizationHeader。您必须将 this.authentication 放入您的 INVITE 消息中。然后您将从事务或对话中发送 SipMessage 到 JAIN-SIP 堆栈。
祝你好运!
关于java - 如何调用 SIP 电话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27946417/
让我先描述一下我的问题。我将 Sofia SIP 用于电话应用程序,而我使用的 SIP 代理位于 NAT 后面。这意味着来自代理的传入邀请将内部代理 IP(例如 10.0.0.1)作为 Contact
我试图找出 的可能值范围接受 和 接受-联系 header 字段,但我在 RFC 中找不到完整列表。有谁知道他们在哪里?我经常看到 Accept: application/sdp;level=1,
我使用的 SIP 服务器通过端口 5070 监听 SIP/TLS 请求。我正在尝试跟踪和分析为什么我的拨号器没有通过 Wireshark 在网络上注册。 我已经在 Wireshark 的首选项中编辑了
我一直非常坚持解决这个问题,我去过几乎所有谈论这个主题的网站(包括旧的堆栈溢出帖子),现在我正在尝试遵循 Android“官方”文档以便让我的 SIP 客户端在我的 Asterisk 服务器上注册,应
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我已经从一个 Asterisk(版本 11.2.1)创建了一个 sip 中继,说“A”服务器到另一个 Asterisk 服务器(11.7.0)说“B”,我得到 sip 响应 200 ok。 但是当我开
我几乎设法发起了一个 2 方通话(点击通话):第一个到我的办公室,第二个到我的手机,使用 Michal Niklas 回答(感谢 Michal) Asterisk click to call . 主要
本地和远程标记以及Call-ID的组合用于识别对话。据说Call-ID是一次调用的唯一值。那么为什么 Call-ID 不单独用于识别对话呢? 最佳答案 一句话:“发夹”。 “Hairpinning”是
我想在SIPBYE报头中获取Custom-Order的值。我尝试使用${sip_yee_h_Custom-Order},但它是空的,因为头名称前没有X前缀。。我可以编辑freeswitch sofia
我在使用以下代码时遇到错误。 我已经包含了 Sip 所需的所有 jar ;但是,我仍然不明白为什么会发生这个错误。你能给我解释一下吗? 我的代码类是: import java.net.InetAddr
我有一个 res_mysql.conf 配置为使用从 db.sql 文件重新填充的一些数据库 db。加载转储后,我重新加载配置,我的 SIP 对等点消失了: dev-ast*CLI> sip show
我正在制作 SIP 电话并且必须开发一个功能来支持多个注册。如果手机的主注册服务器关闭,手机应自动注册到辅助注册器,并在主注册器处于事件状态时再次返回主注册器。我的问题是:如何确定主注册商再次活跃起来
我正在尝试实现一个 sip 服务器以连接到 HTML sip 客户端(使用 sipml5 制作)。在我研究这样做的过程中,我遇到了 sip over web-sockets,这可能对我有用,但是,我不
我需要通过 Lua 脚本在 Kamailio 3.3.1 中设置自定义 header 。理论上我可以像这样在配置脚本中设置一个 - append_hf("X-MyHeader: myvalue\r\n
我需要通过 Lua 脚本在 Kamailio 3.3.1 中设置自定义 header 。理论上我可以像这样在配置脚本中设置一个 - append_hf("X-MyHeader: myvalue\r\n
DTMF 用于一些基于 sip 的软电话来处理负载类型。但是我不清楚使用 DTMF 的过程和重要性。开源软件电话,如 Red5phone和 Sipdroid使用 DTMF。任何人都可以解释这个问题或指
我需要一种在使用 Asterisk 调用文件发起调用时添加 SIP header 的方法。 有什么办法可以在通话文件中添加SIP头吗? 我知道我可以使用 Asterisk AGI 完成此操作,但是我找
我目前在连接到我的 SIP 客户端(IVR 语音服务)的对称 NAT 后面存在 SIP 用户代理问题。 我读到 Asterisk 在 sip.conf 中有一个解决方案,我可以在那里设置属性 nat=
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭11 年前。 Improve th
我的客户公司有一个简单的 Web 应用程序 (Python Flask),我需要向它添加电话通知功能。 主要要求是应用程序应该调用用户、播放某个声音文件并接受一些音调输入(“您好!这是来自您的 Web
我是一名优秀的程序员,十分优秀!