当前位置: 首页>>代码示例>>Java>>正文


Java Response.UNAUTHORIZED属性代码示例

本文整理汇总了Java中javax.sip.message.Response.UNAUTHORIZED属性的典型用法代码示例。如果您正苦于以下问题:Java Response.UNAUTHORIZED属性的具体用法?Java Response.UNAUTHORIZED怎么用?Java Response.UNAUTHORIZED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.sip.message.Response的用法示例。


在下文中一共展示了Response.UNAUTHORIZED属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processResponse

@Override
public void processResponse(ResponseEvent responseEvent) {
    if(responseEvent.getResponse().getStatusCode() == Response.UNAUTHORIZED){
        AuthenticationHelper authenticationHelper =
                mSipStack.getAuthenticationHelper((challengedTransaction, realm) -> mUserCredentials, mHeaderFactory);
        try {
            authenticationHelper.handleChallenge(responseEvent.getResponse(),responseEvent.getClientTransaction(),mSipProvider,2000).sendRequest();
        } catch (SipException e) {
            e.printStackTrace();
        }
    }else if(responseEvent.getResponse().getStatusCode() == Response.OK){
        System.out.println("Login success");
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:14,代码来源:SipClient.java

示例2: processResponse

public void processResponse(ResponseEvent responseReceivedEvent) {
    System.out.println("Got a response");
    Response response = (Response) responseReceivedEvent.getResponse();
    ClientTransaction tid = responseReceivedEvent.getClientTransaction();
    CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);

    System.out.println("Response received : Status Code = "
            + response.getStatusCode() + " " + cseq);
    if (tid == null) {
        System.out.println("Stray response -- dropping ");
        return;
    }
    System.out.println("transaction state is " + tid.getState());
    System.out.println("Dialog = " + tid.getDialog());
    System.out.println("Dialog State is " + tid.getDialog().getState());

    try {
        if (response.getStatusCode() == Response.OK) {
            if (cseq.getMethod().equals(Request.INVITE)) {
                Dialog dialog = inviteTid.getDialog();
                Request ackRequest = dialog.createAck( cseq.getSeqNumber() );
                System.out.println("Sending ACK");
                dialog.sendAck(ackRequest);
            } else if (cseq.getMethod().equals(Request.CANCEL)) {
                if (dialog.getState() == DialogState.CONFIRMED) {
                    // oops cancel went in too late. Need to hang up the
                    // dialog.
                    System.out
                            .println("Sending BYE -- cancel went in too late !!");
                    Request byeRequest = dialog.createRequest(Request.BYE);
                    ClientTransaction ct = sipProvider
                            .getNewClientTransaction(byeRequest);
                    dialog.sendRequest(ct);
                }
            }
        } else if (response.getStatusCode() == Response.PROXY_AUTHENTICATION_REQUIRED
                || response.getStatusCode() == Response.UNAUTHORIZED) {
            AuthenticationHelper authenticationHelper = 
                ((SipStackExt) sipStack).getAuthenticationHelper(new AccountManagerImpl(), headerFactory);
            
            inviteTid = authenticationHelper.handleChallenge(response, tid, sipProvider, 5);
         
            inviteTid.sendRequest();
          
            invco++;
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);
    }

}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:52,代码来源:ShootistAuth.java


注:本文中的javax.sip.message.Response.UNAUTHORIZED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。