Search in sources :

Example 1 with Token

use of gov.nist.core.Token in project XobotOS by xamarin.

the class Parser method sipVersion.

protected String sipVersion() throws ParseException {
    if (debug)
        dbg_enter("sipVersion");
    try {
        Token tok = lexer.match(SIP);
        if (!tok.getTokenValue().equalsIgnoreCase("SIP"))
            createParseException("Expecting SIP");
        lexer.match('/');
        tok = lexer.match(ID);
        if (!tok.getTokenValue().equals("2.0"))
            createParseException("Expecting SIP/2.0");
        return "SIP/2.0";
    } finally {
        if (debug)
            dbg_leave("sipVersion");
    }
}
Also used : Token(gov.nist.core.Token)

Example 2 with Token

use of gov.nist.core.Token in project XobotOS by xamarin.

the class PMediaAuthorizationParser method parse.

public SIPHeader parse() throws ParseException {
    PMediaAuthorizationList mediaAuthorizationList = new PMediaAuthorizationList();
    if (debug)
        dbg_enter("MediaAuthorizationParser.parse");
    try {
        headerName(TokenTypes.P_MEDIA_AUTHORIZATION);
        PMediaAuthorization mediaAuthorization = new PMediaAuthorization();
        mediaAuthorization.setHeaderName(SIPHeaderNamesIms.P_MEDIA_AUTHORIZATION);
        while (lexer.lookAhead(0) != '\n') {
            this.lexer.match(TokenTypes.ID);
            Token token = lexer.getNextToken();
            try {
                mediaAuthorization.setMediaAuthorizationToken(token.getTokenValue());
            } catch (InvalidArgumentException e) {
                throw createParseException(e.getMessage());
            }
            mediaAuthorizationList.add(mediaAuthorization);
            this.lexer.SPorHT();
            if (lexer.lookAhead(0) == ',') {
                this.lexer.match(',');
                mediaAuthorization = new PMediaAuthorization();
            }
            this.lexer.SPorHT();
        }
        return mediaAuthorizationList;
    } finally {
        if (debug)
            dbg_leave("MediaAuthorizationParser.parse");
    }
}
Also used : InvalidArgumentException(javax.sip.InvalidArgumentException) PMediaAuthorization(gov.nist.javax.sip.header.ims.PMediaAuthorization) Token(gov.nist.core.Token) PMediaAuthorizationList(gov.nist.javax.sip.header.ims.PMediaAuthorizationList)

Example 3 with Token

use of gov.nist.core.Token in project XobotOS by xamarin.

the class SecurityAgreeParser method parse.

public SIPHeaderList parse(SecurityAgree header) throws ParseException {
    SIPHeaderList list;
    if (header.getClass().isInstance(new SecurityClient())) {
        list = new SecurityClientList();
    } else if (header.getClass().isInstance(new SecurityServer())) {
        list = new SecurityServerList();
    } else if (header.getClass().isInstance(new SecurityVerify())) {
        list = new SecurityVerifyList();
    } else
        return null;
    // the security-mechanism:
    this.lexer.SPorHT();
    lexer.match(TokenTypes.ID);
    Token type = lexer.getNextToken();
    header.setSecurityMechanism(type.getTokenValue());
    this.lexer.SPorHT();
    char la = lexer.lookAhead(0);
    if (la == '\n') {
        list.add(header);
        return list;
    } else if (la == ';')
        this.lexer.match(';');
    this.lexer.SPorHT();
    // The parameters:
    try {
        while (lexer.lookAhead(0) != '\n') {
            this.parseParameter(header);
            this.lexer.SPorHT();
            char laInLoop = lexer.lookAhead(0);
            if (laInLoop == '\n' || laInLoop == '\0')
                break;
            else if (laInLoop == ',') {
                list.add(header);
                if (header.getClass().isInstance(new SecurityClient())) {
                    header = new SecurityClient();
                } else if (header.getClass().isInstance(new SecurityServer())) {
                    header = new SecurityServer();
                } else if (header.getClass().isInstance(new SecurityVerify())) {
                    header = new SecurityVerify();
                }
                this.lexer.match(',');
                // the security-mechanism:
                this.lexer.SPorHT();
                lexer.match(TokenTypes.ID);
                type = lexer.getNextToken();
                header.setSecurityMechanism(type.getTokenValue());
            }
            this.lexer.SPorHT();
            if (lexer.lookAhead(0) == ';')
                this.lexer.match(';');
            this.lexer.SPorHT();
        }
        list.add(header);
        return list;
    } catch (ParseException ex) {
        throw ex;
    }
}
Also used : SIPHeaderList(gov.nist.javax.sip.header.SIPHeaderList) Token(gov.nist.core.Token) ParseException(java.text.ParseException)

Example 4 with Token

use of gov.nist.core.Token in project XobotOS by xamarin.

the class URLParser method local_phone_number.

private TelephoneNumber local_phone_number(boolean inBrackets) throws ParseException {
    if (debug)
        dbg_enter("local_phone_number");
    TelephoneNumber tn = new TelephoneNumber();
    tn.setGlobal(false);
    NameValueList nv = null;
    String b = null;
    try {
        b = local_number();
        tn.setPhoneNumber(b);
        if (lexer.hasMoreChars()) {
            Token tok = this.lexer.peekNextToken();
            switch(tok.getTokenType()) {
                case SEMICOLON:
                    {
                        if (inBrackets) {
                            this.lexer.consume(1);
                            nv = tel_parameters();
                            tn.setParameters(nv);
                        }
                        break;
                    }
                default:
                    {
                        break;
                    }
            }
        }
    } finally {
        if (debug)
            dbg_leave("local_phone_number");
    }
    return tn;
}
Also used : NameValueList(gov.nist.core.NameValueList) Token(gov.nist.core.Token) TelephoneNumber(gov.nist.javax.sip.address.TelephoneNumber)

Example 5 with Token

use of gov.nist.core.Token in project XobotOS by xamarin.

the class URLParser method phone_context.

/**
     * Parses the 'phone-context' parameter in tel: URLs
     * @throws ParseException
     */
private NameValue phone_context() throws ParseException {
    lexer.match('=');
    char la = lexer.lookAhead(0);
    Object value;
    if (la == '+') {
        // global-number-digits
        // skip '+'
        lexer.consume(1);
        value = "+" + base_phone_number();
    } else if (Lexer.isAlphaDigit(la)) {
        // more broad than allowed
        Token t = lexer.match(Lexer.ID);
        value = t.getTokenValue();
    } else {
        throw new ParseException("Invalid phone-context:" + la, -1);
    }
    return new NameValue("phone-context", value, false);
}
Also used : NameValue(gov.nist.core.NameValue) Token(gov.nist.core.Token) ParseException(java.text.ParseException)

Aggregations

Token (gov.nist.core.Token)10 NameValue (gov.nist.core.NameValue)3 ParseException (java.text.ParseException)3 HostNameParser (gov.nist.core.HostNameParser)1 HostPort (gov.nist.core.HostPort)1 NameValueList (gov.nist.core.NameValueList)1 GenericURI (gov.nist.javax.sip.address.GenericURI)1 SipUri (gov.nist.javax.sip.address.SipUri)1 TelephoneNumber (gov.nist.javax.sip.address.TelephoneNumber)1 SIPHeaderList (gov.nist.javax.sip.header.SIPHeaderList)1 PAccessNetworkInfo (gov.nist.javax.sip.header.ims.PAccessNetworkInfo)1 PMediaAuthorization (gov.nist.javax.sip.header.ims.PMediaAuthorization)1 PMediaAuthorizationList (gov.nist.javax.sip.header.ims.PMediaAuthorizationList)1 InvalidArgumentException (javax.sip.InvalidArgumentException)1