Package javax.sip.header

Examples of javax.sip.header.ProxyAuthorizationHeader


     * @param pass -- the plain text password.
     *
     * @return true if authentication succeded and false otherwise.
     */
    public boolean doAuthenticatePlainTextPassword(Request request, String pass) {
        ProxyAuthorizationHeader authHeader = (ProxyAuthorizationHeader) request.getHeader(ProxyAuthorizationHeader.NAME);
      
        if ( authHeader == null ) return false;
        String realm = authHeader.getRealm();
        String username = authHeader.getUsername();
     
  
        if ( username == null || realm == null ) {
            return false;
        }
       

        String nonce = authHeader.getNonce();
        URI uri = authHeader.getURI();
        if (uri == null) {
           return false;
        }
       

        String A1 = username + ":" + realm + ":" + pass;
        String A2 = request.getMethod().toUpperCase() + ":" + uri.toString();
        byte mdbytes[] = messageDigest.digest(A1.getBytes());
        String HA1 = toHexString(mdbytes);

      
        mdbytes = messageDigest.digest(A2.getBytes());
        String HA2 = toHexString(mdbytes);
     
        String cnonce = authHeader.getCNonce();
        String KD = HA1 + ":" + nonce;
        if (cnonce != null) {
            KD += ":" + cnonce;
        }
        KD += ":" + HA2;
        mdbytes = messageDigest.digest(KD.getBytes());
        String mdString = toHexString(mdbytes);
        String response = authHeader.getResponse();
        return mdString.equals(response);
       
    }
View Full Code Here


        } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      } else { // if Proxy Authentication
        ProxyAuthorizationHeader pah = null;
        try {
          pah = headerFactory
              .createProxyAuthorizationHeader("Digest");
          pah.setUsername(fromUser);
          pah.setRealm(realm);
          pah.setAlgorithm("MD5");
          pah.setURI(uri);
          pah.setNonce(nonce);
          pah.setResponse(toHexString(mdbytes));

          newRequest.setHeader(pah);
        } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
View Full Code Here

TOP

Related Classes of javax.sip.header.ProxyAuthorizationHeader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.