private void initActions()

in modules/auth/src/main/java/common/javax/security/auth/kerberos/ServicePermission.java [49:117]


    private void initActions(String actions) {
        if (actions == null || actions.length() < MIN_LEN) {
            throw new IllegalArgumentException(Messages.getString("auth.2E")); //$NON-NLS-1$
        }

        char[] c_acts = actions.toCharArray();

        int result = 0;
        int ptr = 0;

        int len6 = c_acts.length - ACCEPT_LEN;
        int len8 = c_acts.length - INITIATE_LEN;

        do {
            //skipping whitespaces
            while (ptr <= len6
                    && (c_acts[ptr] == ' ' || c_acts[ptr] == '\t'
                            || c_acts[ptr] == '\n' || c_acts[ptr] == 0x0B
                            || c_acts[ptr] == '\f' || c_acts[ptr] == '\r')) {
                ++ptr;
            }

            if (ptr > len6) {
                // expect string "accept" or "initiate", not just white
                // spaces
                throw new IllegalArgumentException(Messages.getString("auth.2E")); //$NON-NLS-1$
            }

            //parsing string
            if ((c_acts[ptr] == 'a' || c_acts[ptr] == 'A')
                    && (c_acts[ptr + 1] == 'c' || c_acts[ptr + 1] == 'C')
                    && (c_acts[ptr + 2] == 'c' || c_acts[ptr + 2] == 'C')
                    && (c_acts[ptr + 3] == 'e' || c_acts[ptr + 3] == 'E')
                    && (c_acts[ptr + 4] == 'p' || c_acts[ptr + 4] == 'P')
                    && (c_acts[ptr + 5] == 't' || c_acts[ptr + 5] == 'T')) {
                result |= ACCEPT_MASK;
                ptr += ACCEPT_LEN;
            } else if (ptr <= len8
                    && (c_acts[ptr] == 'i' || c_acts[ptr] == 'I')
                    && (c_acts[ptr + 1] == 'n' || c_acts[ptr + 1] == 'N')
                    && (c_acts[ptr + 2] == 'i' || c_acts[ptr + 2] == 'I')
                    && (c_acts[ptr + 3] == 't' || c_acts[ptr + 3] == 'T')
                    && (c_acts[ptr + 4] == 'i' || c_acts[ptr + 4] == 'I')
                    && (c_acts[ptr + 5] == 'a' || c_acts[ptr + 5] == 'A')
                    && (c_acts[ptr + 6] == 't' || c_acts[ptr + 6] == 'T')
                    && (c_acts[ptr + 7] == 'e' || c_acts[ptr + 7] == 'E')) {
                result |= INITIATE_MASK;
                ptr += INITIATE_LEN;
            } else {
                throw new IllegalArgumentException(Messages.getString("auth.2E")); //$NON-NLS-1$
            }

            //skipping trailing whitespaces
            while (ptr < c_acts.length
                    && (c_acts[ptr] == ' ' || c_acts[ptr] == '\t'
                            || c_acts[ptr] == '\n' || c_acts[ptr] == 0x0B
                            || c_acts[ptr] == '\f' || c_acts[ptr] == '\r')) {
                ptr++;
            }

            if (ptr == c_acts.length) {
                this.actions = ACTIONS_TABLE[result];
                return;
            }
        } while (c_acts[ptr++] == ',');

        // unknown trailing symbol
        throw new IllegalArgumentException(Messages.getString("auth.2E")); //$NON-NLS-1$
    }