Return a protocol's signature and finger print from cache

@param protocol a protocol class
@param serverVersion protocol version
@return its signature and finger print
187777
private static ProtocolSigFingerprint getSigFingerprint(
      Class <? extends VersionedProtocol> protocol, long serverVersion) {
    String protocolName = protocol.getName();
    synchronized (PROTOCOL_FINGERPRINT_CACHE) {
      ProtocolSigFingerprint sig = PROTOCOL_FINGERPRINT_CACHE.get(protocolName);
      if (sig == null) {
        int[] serverMethodHashcodes = getFingerprints(protocol.getMethods());
        sig = new ProtocolSigFingerprint(
            new ProtocolSignature(serverVersion, serverMethodHashcodes),
            getFingerprint(serverMethodHashcodes));
        PROTOCOL_FINGERPRINT_CACHE.put(protocolName, sig);
      }
      return sig;
    }
  }
519307
@Override
    public String getIdentity() {
        return protocol + Constants.PROTOCOL_SEPARATOR + host + ":" + port +
                "/" + getParameter(URLParamType.group.getName(), URLParamType.group.getValue()) + "/" +
                getPath() + "/" + getParameter(URLParamType.version.getName(), URLParamType.version.getValue()) +
                "/" + getParameter(URLParamType.nodeType.getName(), URLParamType.nodeType.getValue());
    }
898678
public static String getFieldSignature(String name, String rawSignature) {
        StringBuilder signature = new StringBuilder();
        String returnType = org.objectweb.asm.Type.getType(rawSignature).getClassName();
        signature.append(returnType);
        signature.append(' ');
        signature.append(name);
        return signature.toString();
    }
338699
public static ProtocolDetectionResult<HAProxyProtocolVersion> detectProtocol(ByteBuf buffer) {
        if (buffer.readableBytes() < 12) {
            return ProtocolDetectionResult.needsMoreData();
        }

        int idx = buffer.readerIndex();

        if (match(BINARY_PREFIX, buffer, idx)) {
            return DETECTION_RESULT_V2;
        }
        if (match(TEXT_PREFIX, buffer, idx)) {
            return DETECTION_RESULT_V1;
        }
        return ProtocolDetectionResult.invalid();
    }
1257545
private static function fetchProtocolVersion(string $version): string
    {
        $v = substr($version, 5);

        if ($v === '2.0') {
            return '2';
        }

        // Fallback for values outside of valid protocol versions
        if (!in_array($v, static::$allowedVersions, true)) {
            return '1.1';
        }

        return $v;
    }
518444
protected NodeData getBaseVersionData(final NodeData node, final SessionImpl session) throws RepositoryException
   {

      NodeTypeDataManager ntManager = session.getWorkspace().getNodeTypesHolder();
      if (ntManager.isNodeType(Constants.MIX_VERSIONABLE, node.getPrimaryTypeName(), node.getMixinTypeNames()))
      {

         SessionDataManager dmanager = session.getTransientNodesManager();

         PropertyData bvProperty =
            (PropertyData)dmanager.getItemData(node, new QPathEntry(Constants.JCR_BASEVERSION, 0), ItemType.PROPERTY);

         return (NodeData)dmanager.getItemData(ValueDataUtil.getString(bvProperty.getValues().get(0)));
      }

      return null; // non versionable
   }
529135
function packetlistCloneToSignatures(clone) {
  clone.keyid = type_keyid.fromClone(clone.keyid);
  if (util.isStream(clone.signature)) {
    clone.signature = stream.readToEnd(clone.signature, ([signature]) => new Signature(List.fromStructuredClone(signature)));
    clone.signature.catch(() => {});
  } else {
    clone.signature = new Signature(List.fromStructuredClone(clone.signature));
  }
  clone.verified = stream.readToEnd(clone.verified, ([verified]) => verified);
  clone.verified.catch(() => {});
  if (clone.error) {
    clone.error = new Error(clone.error);
  }
  return clone;
}
892671
public static AsteriskVersion getDetermineVersionFromString(String coreLine)
    {
        for (AsteriskVersion version : knownVersions)
        {
            for (Pattern pattern : version.patterns)
            {
                if (pattern.matcher(coreLine).matches())
                {
                    return version;
                }
            }
        }

        return null;
    }
1033993
public String getTypeSignature(String javasignature, TypeMirror returnType)
            throws SignatureException {
        String signature = null; //Java type signature.
        String typeSignature = null; //Internal type signature.
        List<String> params = new ArrayList<>(); //List of parameters.
        String paramsig = null; //Java parameter signature.
        String paramJVMSig = null; //Internal parameter signature.
        String returnSig = null; //Java return type signature.
        String returnJVMType = null; //Internal return type signature.
        int dimensions = 0; //Array dimension.

        int startIndex = -1;
        int endIndex = -1;
        StringTokenizer st = null;
        int i = 0;

        // Gets the actual java signature without parentheses.
        if (javasignature != null) {
            startIndex = javasignature.indexOf("(");
            endIndex = javasignature.indexOf(")");
        }

        if (((startIndex != -1) && (endIndex != -1))
            &&(startIndex+1 < javasignature.length())
            &&(endIndex < javasignature.length())) {
            signature = javasignature.substring(startIndex+1, endIndex);
        }

        // Separates parameters.
        if (signature != null) {
            if (signature.contains(",")) {
                st = new StringTokenizer(signature, ",");
                if (st != null) {
                    while (st.hasMoreTokens()) {
                        params.add(st.nextToken());
                    }
                }
            } else {
                params.add(signature);
            }
        }

        /* JVM type signature. */
        typeSignature = "(";

        // Gets indivisual internal parameter signature.
        while (params.isEmpty() != true) {
            paramsig = params.remove(i).trim();
            paramJVMSig  = getParamJVMSignature(paramsig);
            if (paramJVMSig != null) {
                typeSignature += paramJVMSig;
            }
        }

        typeSignature += ")";

        // Get internal return type signature.

        returnJVMType = "";
        if (returnType != null) {
            dimensions = dimensions(returnType);
        }

        //Gets array dimension of return type.
        while (dimensions-- > 0) {
            returnJVMType += "[";
        }
        if (returnType != null) {
            returnSig = qualifiedTypeName(returnType);
            returnJVMType += getComponentType(returnSig);
        } else {
            System.out.println("Invalid return type.");
        }

        typeSignature += returnJVMType;

        return typeSignature;
    }
1296435
private static function aggregateHttpProtocolVersionFromServer($server)
    {
        if (!isset($server['SERVER_PROTOCOL'])) {
            return null;
        }

        $pattern = '/^(?P<scheme>HTTP)\/(?P<protocol_version>1\.(0|1))$/';

        if (!preg_match($pattern, $server['SERVER_PROTOCOL'], $q)) {
            return null;
        }

        return $q['protocol_version'];
    }
1307278
private static String toJavaCipherSuitePrefix(String protocolVersion) {
        final char c;
        if (protocolVersion == null || protocolVersion.isEmpty()) {
            c = 0;
        } else {
            c = protocolVersion.charAt(0);
        }

        switch (c) {
            case 'T':
                return "TLS";
            case 'S':
                return "SSL";
            default:
                return "UNKNOWN";
        }
    }
940709
public String generateFingerprint(String hashFunction) {
		try {
			this.hashFunction = hashFunction;
			org.bouncycastle.crypto.tls.Certificate chain = TlsUtils.loadCertificateChain(certificateResources);
			Certificate certificate = chain.getCertificateAt(0);
			return TlsUtils.fingerprint(this.hashFunction, certificate);
		} catch (IOException e) {
			LOGGER.error("Could not get local fingerprint: "+ e.getMessage());
			return "";
		}
	}
1280846
public byte[] getFingerprintFromInputStream(InputStream inputStream) {
        byte[] fingerprint = null;
        try {
            fingerprint = new byte[inputStream.available()];
            inputStream.read(fingerprint);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return fingerprint;
    }
1174524
public List<Peer> findPeersOfAtLeastVersion(long protocolVersion) {
        lock.lock();
        try {
            ArrayList<Peer> results = new ArrayList<>(peers.size());
            for (Peer peer : peers)
                if (peer.getPeerVersionMessage().clientVersion >= protocolVersion)
                    results.add(peer);
            return results;
        } finally {
            lock.unlock();
        }
    }
965366
public static String fingerprint( X509Certificate cert ) throws CertificateException
    {
        try
        {
            MessageDigest md = MessageDigest.getInstance( "SHA-512" );
            md.update( cert.getEncoded() );
            return ByteBufUtil.hexDump( md.digest() );
        }
        catch( NoSuchAlgorithmException e )
        {
            // SHA-1 not available
            throw new CertificateException( "Cannot use TLS on this platform, because SHA-512 message digest algorithm is not available: " + e.getMessage(), e );
        }
    }
1250994
def get_fp_version(self):
        
        command = const.CMD_OPTIONS_RRQ
        command_string = b'~ZKFPVersion\x00'
        response_size = 1024

        cmd_response = self.__send_command(command, command_string, response_size)
        if cmd_response.get('status'):
            response = self.__data.split(b'=', 1)[-1].split(b'\x00')[0]
            response = response.replace(b'=', b'')
            return safe_cast(response, int, 0) if response else 0
        else:
            raise ZKErrorResponse("can't read fingerprint version")
27879
public final I getInvocation(Object protocolKey)
  {
    I invocation = null;

    // XXX: see if can remove this
    LruCache<Object,I> invocationCache = _invocationCache;

    if (invocationCache != null) {
      invocation = invocationCache.get(protocolKey);
    }

    if (invocation == null) {
      return null;
    }
    else if (invocation.isModified()) {
      return null;
    }
    else {
      return invocation;
    }
  }