Retrieves the actual value of the X.509 extension.

@param certExtValue the DER-encoded OCTET string value of the extension.
@return the decoded/actual value of the extension (the octets).
482793
public static byte[] getExtensionValue(byte [] certExtValue)
	throws IOException {
	ByteArrayInputStream inStream = new ByteArrayInputStream(certExtValue);
	ASN1InputStream derInputStream = new ASN1InputStream(inStream);
        ASN1Primitive object = derInputStream.readObject();
	if (object instanceof ASN1OctetString) {
	    return ((ASN1OctetString)object).getOctets();
	} else {
	    throw new IOException(i18n.getMessage("octectExp"));
	}
    }
672121
def value(self):
        
        length = self._value.find(b'\x00')
        if length >= 0:
            return self._value[:length].decode('ascii')
        else:
            return self._value.decode('ascii')
1230210
int getIndirectCE32(int ce32) {
        assert(Collation.isSpecialCE32(ce32));
        int tag = Collation.tagFromCE32(ce32);
        if(tag == Collation.DIGIT_TAG) {
            // Fetch the non-numeric-collation CE32.
            ce32 = ce32s[Collation.indexFromCE32(ce32)];
        } else if(tag == Collation.LEAD_SURROGATE_TAG) {
            ce32 = Collation.UNASSIGNED_CE32;
        } else if(tag == Collation.U0000_TAG) {
            // Fetch the normal ce32 for U+0000.
            ce32 = ce32s[0];
        }
        return ce32;
    }
869013
public static EnumSet<KeyUsage> getKeyUsage(X509Extension ext)
            throws IOException {
        DERBitString bits = (DERBitString) getExtensionObject(ext);
        EnumSet<KeyUsage> keyUsage = EnumSet.noneOf(KeyUsage.class);
        for (KeyUsage bit: KeyUsage.values()) {
            if (bit.isSet(bits)) {
                keyUsage.add(bit);
            }
        }
        return keyUsage;
    }
902375
public static String getVertexId(Value value) {
        byte[] buffer = value.get();
        int offset = 0;

        // skip label
        int strLen = readInt(buffer, offset);
        offset += 4;
        if (strLen > 0) {
            offset += strLen;
        }

        strLen = readInt(buffer, offset);
        return readString(buffer, offset, strLen);
    }
1312300
private void fetchEscapedValue() {
        if (!left()) newSyntaxException(END_PATTERN_AT_ESCAPE);
        fetch();

        switch(c) {

        case 'M':
            if (syntax.op2EscCapitalMBarMeta()) {
                if (!left()) newSyntaxException(END_PATTERN_AT_META);
                fetch();
                if (c != '-') newSyntaxException(META_CODE_SYNTAX);
                if (!left()) newSyntaxException(END_PATTERN_AT_META);
                fetch();
                if (c == syntax.metaCharTable.esc) fetchEscapedValue();
                c = ((c & 0xff) | 0x80);
            } else {
                fetchEscapedValueBackSlash();
            }
            break;

        case 'C':
            if (syntax.op2EscCapitalCBarControl()) {
                if (!left()) newSyntaxException(END_PATTERN_AT_CONTROL);
                fetch();
                if (c != '-') newSyntaxException(CONTROL_CODE_SYNTAX);
                fetchEscapedValueControl();
            } else {
                fetchEscapedValueBackSlash();
            }
            break;

        case 'c':
            if (syntax.opEscCControl()) {
                fetchEscapedValueControl();
            }
            /* fall through */

        default:
            fetchEscapedValueBackSlash();
        } // switch
    }
224048
private int resolveCharEnt(StringBuffer originalCharacters)
        throws XMLStreamException
    {
        int value = 0;
        char c = getNextChar(SUFFIX_IN_ENTITY_REF);
        
        if (originalCharacters != null) {
            originalCharacters.append(c);
        }
        
        if (c == 'x') { // hex
            while (true) {
                c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++]
                    : getNextCharFromCurrent(SUFFIX_IN_ENTITY_REF);
                if (c == ';') {
                    break;
                }
                
                if (originalCharacters != null) {
                    originalCharacters.append(c);
                }
                value = value << 4;
                if (c <= '9' && c >= '0') {
                    value += (c - '0');
                } else if (c >= 'a' && c <= 'f') {
                    value += 10 + (c - 'a');
                } else if (c >= 'A' && c <= 'F') {
                    value += 10 + (c - 'A');
                } else {
                    throwUnexpectedChar(c, "; expected a hex digit (0-9a-fA-F).");
                }
                // Overflow?
                if (value > MAX_UNICODE_CHAR) {
                    reportUnicodeOverflow();
                }
            }
        } else { // numeric (decimal)
            while (c != ';') {
                if (c <= '9' && c >= '0') {
                    value = (value * 10) + (c - '0');
                    // Overflow?
                    if (value > MAX_UNICODE_CHAR) {
                        reportUnicodeOverflow();
                    }
                } else {
                    throwUnexpectedChar(c, "; expected a decimal number.");
                }
                c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++]
                    : getNextCharFromCurrent(SUFFIX_IN_ENTITY_REF);
                
                if (originalCharacters != null && c != ';') {
                    originalCharacters.append(c);
                }
            }
        }
        validateChar(value);
        return value;
    }
517888
private void parse(DerValue val)
        throws IOException, CertificateException
    {
        if (val.tag != DerValue.tag_Sequence) {
            throw new IOException
                ("Sequence tag missing for X509CertificatePair");
        }

        while (val.data != null && val.data.available() != 0) {
            DerValue opt = val.data.getDerValue();
            short tag = (byte) (opt.tag & 0x01f);
            switch (tag) {
                case TAG_FORWARD:
                    if (opt.isContextSpecific() && opt.isConstructed()) {
                        if (forward != null) {
                            throw new IOException("Duplicate forward "
                                + "certificate in X509CertificatePair");
                        }
                        opt = opt.data.getDerValue();
                        forward = X509Factory.intern
                                        (new X509CertImpl(opt.toByteArray()));
                    }
                    break;
                case TAG_REVERSE:
                    if (opt.isContextSpecific() && opt.isConstructed()) {
                        if (reverse != null) {
                            throw new IOException("Duplicate reverse "
                                + "certificate in X509CertificatePair");
                        }
                        opt = opt.data.getDerValue();
                        reverse = X509Factory.intern
                                        (new X509CertImpl(opt.toByteArray()));
                    }
                    break;
                default:
                    throw new IOException("Invalid encoding of "
                        + "X509CertificatePair");
            }
        }
        if (forward == null && reverse == null) {
            throw new CertificateException("at least one of certificate pair "
                + "must be non-null");
        }
    }
297643
public String getDecimalPart(final int digit) {
        
        final int length = decimalPart.length();
        if(length < digit || digit <= 0) {
            return "";
        }
        
        return String.valueOf(decimalPart.charAt(digit-1));
        
    }
1148405
def get_cursed_value
    return nil unless @field

    x = Ncurses.curx
    form_driver_key Ncurses::Form::REQ_VALIDATION
    v = @field.field_buffer(0).gsub(/^\s+|\s+$/, "")

    ## cursor <= end of text
    if x - @question.length - v.length <= 0
      v
    else # trailing spaces
      v + (" " * (x - @question.length - v.length))
    end

    # ncurses returns a ASCII-8BIT (binary) string, which
    # bytes presumably are of current charset encoding. we force_encoding
    # so that the char representation / string is tagged will be the
    # system locale and also hopefully the terminal/input encoding. an
    # incorrectly configured terminal encoding (not matching the system
    # encoding) will produce erronous results, but will also do that for
    # a lot of other programs since it is impossible to detect which is
    # which and what encoding the inputted byte chars are supposed to have.
    v.force_encoding($encoding).fix_encoding!
  end
1119053
private static String getValue(JSONTokener x) throws JSONException {
    char c;
    char q;
    StringBuffer sb;
    do {
      c = x.next();
    } while (c == ' ' || c == '\t');
    switch (c) {
    case 0:
      return null;
    case '"':
    case '\'':
      q = c;
      sb = new StringBuffer();
      for (;;) {
        c = x.next();
        if (c == q) {
          break;
        }
        if (c == 0 || c == '\n' || c == '\r') {
          throw x.syntaxError("Missing close quote '" + q + "'.");
        }
        sb.append(c);
      }
      return sb.toString();
    case ',':
      x.back();
      return "";
    default:
      x.back();
      return x.nextTo(',');
    }
  }
395874
private List<String> getCrlDistributionPoints(X509Certificate cert) throws CertificateVerificationException {

        //Gets the DER-encoded OCTET string for the extension value for CRLDistributionPoints.
        byte[] crlDPExtensionValue = cert.getExtensionValue(Extension.cRLDistributionPoints.getId());
        if (crlDPExtensionValue == null) {
            throw new CertificateVerificationException("Certificate doesn't have CRL distribution points");
        }
        //crlDPExtensionValue is encoded in ASN.1 format.
        ASN1InputStream asn1In = new ASN1InputStream(crlDPExtensionValue);
        //DER (Distinguished Encoding Rules) is one of ASN.1 encoding rules defined in ITU-T X.690, 2002, specification.
        //ASN.1 encoding rules can be used to encode any data object into a binary file. Read the object in octets.
        CRLDistPoint distPoint;
        try {
            DEROctetString crlDEROctetString = (DEROctetString) asn1In.readObject();
            //Get Input stream in octets.
            distPoint = getOctetInputStream(crlDEROctetString);
        } catch (IOException e) {
            throw new CertificateVerificationException("Cannot read certificate to get CRL URLs", e);
        } finally {
            try {
                asn1In.close();
            } catch (IOException e) {
                LOG.error("Cannot close input stream", e);
            }
        }

        List<String> crlUrls = new ArrayList<>();
        //Loop through ASN1Encodable DistributionPoints.
        for (DistributionPoint dp : distPoint.getDistributionPoints()) {
            //get ASN1Encodable DistributionPointName.
            DistributionPointName dpn = dp.getDistributionPoint();
            if (dpn != null && dpn.getType() == DistributionPointName.FULL_NAME) {
                //Create ASN1Encodable General Names.
                GeneralName[] genNames = GeneralNames.getInstance(dpn.getName()).getNames();
                // Look for a URI
                for (GeneralName genName : genNames) {
                    if (genName.getTagNo() == GeneralName.uniformResourceIdentifier) {
                        //DERIA5String contains an ascii string.
                        //A IA5String is a restricted character string type in the ASN.1 notation.
                        String url = DERIA5String.getInstance(genName.getName()).getString().trim();
                        crlUrls.add(url);
                    }
                }
            }
        }

        if (crlUrls.isEmpty()) {
            throw new CertificateVerificationException("Cant get CRL urls from certificate");
        }
        return crlUrls;
    }
454776
public int getPrefixValueCount() {
		Integer prefixLength = getSegmentPrefixLength();
		if(prefixLength == null) {
			return getValueCount();
		}
		int shiftAdjustment = getBitCount() - prefixLength;
		return (getUpperSegmentValue() >>> shiftAdjustment) - (getSegmentValue() >>> shiftAdjustment) + 1;
	}
894880
public int uIntValue() throws OtpErlangRangeException {
        final long l = longValue();
        final int i = (int) l;

        if (i != l) {
            throw new OtpErlangRangeException("Value too large for int: " + val);
        } else if (i < 0) {
            throw new OtpErlangRangeException("Value not positive: " + val);
        }

        return i;
    }
831841
public static List<String> getExtendedKeyUsage(X509Certificate cert)
        throws CertificateParsingException {
        try {
            byte[] ext = cert.getExtensionValue(EXTENDED_KEY_USAGE_OID);
            if (ext == null)
                return null;
            DerValue val = new DerValue(ext);
            byte[] data = val.getOctetString();

            ExtendedKeyUsageExtension ekuExt =
                new ExtendedKeyUsageExtension(Boolean.FALSE, data);
            return Collections.unmodifiableList(ekuExt.getExtendedKeyUsage());
        } catch (IOException ioe) {
            throw new CertificateParsingException(ioe);
        }
    }
855458
public static String getStringValue(@NonNull byte[] value, @IntRange(from = 0) int offset) {
        if (offset > value.length) {
            RxBleLog.w("Passed offset that exceeds the length of the byte array - returning null");
            return null;
        }
        byte[] strBytes = new byte[value.length - offset];
        for (int i = 0; i != (value.length - offset); ++i) {
            strBytes[i] = value[offset + i];
        }
        return new String(strBytes);
    }
1305299
private CharSequence getSettingsHeaderValue(ChannelHandlerContext ctx) {
        ByteBuf buf = null;
        ByteBuf encodedBuf = null;
        try {
            // Get the local settings for the handler.
            Http2Settings settings = connectionHandler.decoder().localSettings();

            // Serialize the payload of the SETTINGS frame.
            int payloadLength = SETTING_ENTRY_LENGTH * settings.size();
            buf = ctx.alloc().buffer(payloadLength);
            for (CharObjectMap.PrimitiveEntry<Long> entry : settings.entries()) {
                buf.writeChar(entry.key());
                buf.writeInt(entry.value().intValue());
            }

            // Base64 encode the payload and then convert to a string for the header.
            encodedBuf = Base64.encode(buf, URL_SAFE);
            return encodedBuf.toString(UTF_8);
        } finally {
            release(buf);
            release(encodedBuf);
        }
    }