SDK4.0 signature
541960
public Task revertToSnapshot_Task(HostSystem host, Boolean suppressPowerOn) throws VmConfigFault, TaskInProgress, FileFault, InvalidState, InsufficientResourcesFault, RuntimeFault, RemoteException {
        return new Task(getServerConnection(),
            getVimService().revertToSnapshot_Task(getMOR(), host == null ? null : host.getMOR(), suppressPowerOn));
    }
38596
private void genClassSignature(TypeElement type, StringBuilder sb) {
    genOptFormalTypeParameters(type.getTypeParameters(), sb);
    // JDT returns null for an interface's superclass, but signatures expect Object.
    if (type.getKind().isInterface()) {
      sb.append(JAVA_OBJECT_SIGNATURE);
    } else {
      genTypeSignature(type.getSuperclass(), sb);
    }
    for (TypeMirror intrface : type.getInterfaces()) {
      genTypeSignature(intrface, sb);
    }
  }
1178227
def apply_signature(cls, instance, async=True, countdown=None, is_heavy_task=False, **kwargs):
        
        serialized_instance = utils.serialize_instance(instance)

        signature = cls.get_task_signature(instance, serialized_instance, **kwargs)
        link = cls.get_success_signature(instance, serialized_instance, **kwargs)
        link_error = cls.get_failure_signature(instance, serialized_instance, **kwargs)

        if async:
            return signature.apply_async(link=link, link_error=link_error, countdown=countdown,
                                         queue=is_heavy_task and 'heavy' or None)
        else:
            result = signature.apply()
            callback = link if not result.failed() else link_error
            if callback is not None:
                cls._apply_callback(callback, result)

        return result.get()
1214383
String signature(ExecutableElement e) {
        StringBuilder sb = new StringBuilder("(");
        String sep = "";
        for (VariableElement p: e.getParameters()) {
            sb.append(sep);
            sb.append(types.erasure(p.asType()).toString());
            sep = ",";
        }
        sb.append(")");
        return sb.toString();
    }
1192582
async def fetch_signatures(endpoint, protocol, idgen):
        """"""
        async with aiohttp.ClientSession() as session:
            req = {
                "method": "getMethodTypes",
                "params": [''],
                "version": "1.0",
                "id": next(idgen),
            }

            if protocol == ProtocolType.WebSocket:
                async with session.ws_connect(endpoint, timeout=2) as s:
                    await s.send_json(req)
                    res = await s.receive_json()
                    return res
            else:
                res = await session.post(endpoint, json=req)
                json = await res.json()

                return json
1080270
function Signature(req, buf) {
  this.req = req;
  this.rawBody = buf || req.rawBody;

  this.xSignature = (req.headers['x-signature'] || '').split(' ');
  this.signature = base64url.toBuffer(this.xSignature[0] || '');
  this.publicKey = base64url.toBuffer(this.xSignature[1] || '');
  this.endorsement = base64url.toBuffer(this.xSignature[2] || '');

  this.date = Date.parse(req.headers.date);
}
697284
static void sign(SignableSAMLObject signableObj, Credential signingCredential, String signatureAlgorithm) {
        requireNonNull(signableObj, "signableObj");
        requireNonNull(signingCredential, "signingCredential");
        requireNonNull(signatureAlgorithm, "signatureAlgorithm");

        final Signature signature = signatureBuilder.buildObject();
        signature.setSignatureAlgorithm(signatureAlgorithm);
        signature.setSigningCredential(signingCredential);
        signature.setCanonicalizationAlgorithm(ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
        try {
            signature.setKeyInfo(keyInfoGenerator.generate(signingCredential));
        } catch (SecurityException e) {
            throw new SamlException("failed to create a key info of signing credential", e);
        }

        signableObj.setSignature(signature);
        serialize(signableObj);

        try {
            Signer.signObject(signature);
        } catch (SignatureException e) {
            throw new SamlException("failed to sign a SAML object", e);
        }
    }
427769
private void assertIsFromSns(URI certUrl) {
        if (!endpoint.equals(certUrl.getHost())) {
            throw new SdkClientException(
                String.format("SigningCertUrl does not match expected endpoint. Expected %s but received endpoint was %s.",
                              endpoint, certUrl.getHost()));

        }
    }
980002
private static String getSignature(MethodLiteral<?, ?> method, String[] paramNames,
      String overrideName, int overrideModifiers) throws NoSourceNameException {
    if (paramNames.length != method.getParameterTypes().size()) {
      throw new IllegalArgumentException(
          String.format("Wrong number of parameters provided for method signature, "
              + "expected %d but got %d.", method.getParameterTypes().size(), paramNames.length));
    }

    StringBuilder sb = new StringBuilder();

    if (overrideModifiers != 0) {
      sb.append(Modifier.toString(overrideModifiers)).append(" ");
    }

    if (method.getTypeParameters().length > 0) {
      List<String> typeParameters = new ArrayList<String>();
      for (TypeVariable<?> typeVariable : method.getTypeParameters()) {
        typeParameters.add(getTypeVariableDefinition(typeVariable));
      }
      sb.append("<").append(join(", ", typeParameters)).append("> ");
    }

    if (!method.isConstructor()) {
      sb.append(getSourceName(method.getReturnType())).append(" ");
      if (overrideName != null) {
        sb.append(overrideName);
      } else {
        sb.append(method.getName());
      }
    } else {
      sb.append(getSourceName(method.getRawDeclaringType()));
    }
    sb.append("(");

    // TODO(schmitt): We are not respecting varargs here.
    List<String> parameters = new ArrayList<String>();
    int i = 0;
    for (TypeLiteral<?> parameterType : method.getParameterTypes()) {
      parameters.add(
          String.format("%s %s", getSourceName(parameterType), paramNames[i]));
      i++;
    }
    sb.append(join(", ", parameters)).append(")");

    if (method.getExceptionTypes().size() > 0) {
      List<String> exceptions = new ArrayList<String>();
      for (TypeLiteral<?> exceptionType : method.getExceptionTypes()) {
        exceptions.add(getSourceName(exceptionType));
      }
      sb.append(" throws ").append(join(", ", exceptions));
    }

    return sb.toString();
  }
705276
private void writeSignatureBlock(Signature signature, X509Certificate publicKey,
            PrivateKey privateKey)
            throws IOException, GeneralSecurityException {
        SignerInfo signerInfo = new SignerInfo(
                new X500Name(publicKey.getIssuerX500Principal().getName()),
                publicKey.getSerialNumber(),
                AlgorithmId.get(DIGEST_ALGORITHM),
                AlgorithmId.get(privateKey.getAlgorithm()),
                signature.sign());

        PKCS7 pkcs7 = new PKCS7(
                new AlgorithmId[] { AlgorithmId.get(DIGEST_ALGORITHM) },
                new ContentInfo(ContentInfo.DATA_OID, null),
                new X509Certificate[] { publicKey },
                new SignerInfo[] { signerInfo });

        pkcs7.encodeSignedData(mOutputJar);
    }
726146
public static SignatureUtil buildInstance(String privateKey, String publicKey,
                                              Algorithms algorithms) {
        return new SignatureUtilImpl(privateKey, publicKey, algorithms);
    }
103833
static String createAuthorizationSignatureV4(
            HttpServletRequest request, S3AuthorizationHeader authHeader,
            byte[] payload, String uri, String credential)
            throws InvalidKeyException, IOException, NoSuchAlgorithmException,
            S3Exception {
        String canonicalRequest = createCanonicalRequest(request, uri, payload,
                authHeader.hashAlgorithm);
        String algorithm = authHeader.hmacAlgorithm;
        byte[] dateKey = signMessage(
                authHeader.date.getBytes(StandardCharsets.UTF_8),
                ("AWS4" + credential).getBytes(StandardCharsets.UTF_8),
                algorithm);
        byte[] dateRegionKey = signMessage(
                authHeader.region.getBytes(StandardCharsets.UTF_8), dateKey,
                algorithm);
        byte[] dateRegionServiceKey = signMessage(
                authHeader.service.getBytes(StandardCharsets.UTF_8),
                dateRegionKey, algorithm);
        byte[] signingKey = signMessage(
                "aws4_request".getBytes(StandardCharsets.UTF_8),
                dateRegionServiceKey, algorithm);
        String date = request.getHeader(AwsHttpHeaders.DATE);
        if (date == null) {
            date = request.getParameter("X-Amz-Date");
        }
        String signatureString = "AWS4-HMAC-SHA256\n" +
                date + "\n" +
                authHeader.date + "/" + authHeader.region +
                "/s3/aws4_request\n" +
                canonicalRequest;
        byte[] signature = signMessage(
                signatureString.getBytes(StandardCharsets.UTF_8),
                signingKey, algorithm);
        return BaseEncoding.base16().lowerCase().encode(signature);
    }
1261209
protected final void validateAssertionSignature(final Signature signature, final SAML2MessageContext context,
                                                    final SignatureTrustEngine engine) {

        final SAMLPeerEntityContext peerContext = context.getSAMLPeerEntityContext();

        if (signature != null) {
            final String entityId = peerContext.getEntityId();
            validateSignature(signature, entityId, engine);
        } else {
            if (wantsAssertionsSigned(context) && !peerContext.isAuthenticated()) {
                throw new SAMLSignatureRequiredException("Assertion or response must be signed");
            }
        }
    }
277074
@FFDCIgnore(Exception.class)
    protected void initSigningKey(BuilderImpl jwtBuilder, JwtConfig jwtConfig) throws JwtTokenException {
        String keyType = Constants.SIGNING_KEY_X509;
        try {
            if (jwtConfig.isJwkEnabled() && SIGNATURE_ALG_RS256.equals(signatureAlgorithm)) {
                keyType = Constants.SIGNING_KEY_JWK;
                if (tc.isDebugEnabled()) {
                    Tr.debug(tc, "Signing key type is " + keyType);
                }
                JSONWebKey jwk = jwtConfig.getJSONWebKey();
                if (jwk == null) {
                    if (tc.isDebugEnabled()) {
                        Tr.debug(tc, "Did not succcessfully build a JWK");
                    }
                    _signingKey = null;
                    _keyId = null;
                } else {
                    _signingKey = jwk.getPrivateKey();
                    _keyId = jwk.getKeyID();
                }
            } else {
                if (SIGNATURE_ALG_HS256.equals(signatureAlgorithm)) {
                    keyType = Constants.SIGNING_KEY_SECRET;
                    if (tc.isDebugEnabled()) {
                        Tr.debug(tc, "Signing key type is " + keyType);
                    }
                    String sharedKey = jwtBuilder.getSharedKey();
                    if (JwtUtils.isNullEmpty(sharedKey)) {
                        sharedKey = jwtConfig.getSharedKey();
                    }
                    if (!JwtUtils.isNullEmpty(sharedKey)) {
                        _signingKey = new HmacKey(sharedKey.getBytes("UTF-8"));
                    } else {
                        _signingKey = null;
                    }

                } else if (SIGNATURE_ALG_RS256.equals(signatureAlgorithm)) {
                    _signingKey = jwtBuilder.getKey();
                    if (tc.isDebugEnabled()) {
                        Tr.debug(tc, "Signing key type is " + keyType);
                    }
                    if (_signingKey == null) {
                        String keyAlias = null;
                        String keyStoreRef = null;
                        keyAlias = jwtConfig.getKeyAlias();
                        keyStoreRef = jwtConfig.getKeyStoreRef();
                        _signingKey = JwtUtils.getPrivateKey(keyAlias, keyStoreRef);
                        _keyId = buildKidFromPublicKey(JwtUtils.getPublicKey(keyAlias, keyStoreRef));
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Key alias: " + keyAlias + ", Keystore: " + keyStoreRef+ ", kid: " + _keyId);
                        }
                    }

                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "RSAPrivateKey: " + (_signingKey instanceof RSAPrivateKey));
                    }
                    if (_signingKey != null && !(_signingKey instanceof RSAPrivateKey)) {
                        // error handling
                        // String errorMsg = Tr.formatMessage(tc, "SIGNING_KEY_NOT_RSA", new Object[] { signatureAlgorithm });
                        // Object[] objs = new Object[] { signatureAlgorithm, errorMsg };
                        // noKeyException = JWTTokenException.newInstance(false, "JWT_BAD_SIGNING_KEY", objs);
                        _signingKey = null; // we will catch this later in jwtSigner
                        _keyId = null;
                    }
                }
            }
        } catch (Exception e) {
            // UnsupportedEncodingException e (won't happen)
            // if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            // Tr.debug(tc, "Exception obtaining the signing key: " + e);
            // }
            // error messages
            // JWT_BAD_SIGNING_KEY=CWWKS1455E: A signing key was not available. The signature algorithm is [{0}]. {1}

            Object[] objs = new Object[] { signatureAlgorithm, jwtConfig.isJwkEnabled(), e.getLocalizedMessage() }; // let JWTTokenException handle the exception
            JwtTokenException jte = JwtTokenException.newInstance(false, "JWT_NO_SIGNING_KEY_WITH_ERROR", objs);
            jte.initCause(e);
            throw jte;
        }
        if (_signingKey == null) {
            Object[] objs = new Object[] { signatureAlgorithm, jwtConfig.isJwkEnabled(), "" }; // let JWTTokenException handle the exception
            throw JwtTokenException.newInstance(true, "JWT_NO_SIGNING_KEY_WITH_ERROR", objs);
        }
    }
27189
@Override
    public Builder signWith(String algorithm, Key key) throws KeyException {

        if (algorithm == null || algorithm.isEmpty() || !algorithm.equals(Constants.SIGNATURE_ALG_RS256)) {
            String err = Tr.formatMessage(tc, "JWT_INVALID_ALGORITHM_ERR", new Object[] { algorithm, Constants.SIGNATURE_ALG_RS256 });
            throw new KeyException(err);
        }
        if (key == null || !(key instanceof RSAPrivateKey)) {
            String err = Tr.formatMessage(tc, "JWT_INVALID_KEY_ERR", new Object[] { algorithm, key });
            throw new KeyException(err);
        }
        alg = algorithm;
        privateKey = key;
        return this;
    }
1257516
def get_signatures(self, limit=100, offset=0, conditions={}):
        
        url = self.SIGNS_URL + "?limit=%s&offset=%s" % (limit, offset)

        for key, value in conditions.items():
            if key is 'ids':
                value = ",".join(value)

            url += '&%s=%s' % (key, value)

        connection = Connection(self.token)
        connection.set_url(self.production, url)

        return connection.get_request()
860788
def sign(key, qs):
    """"""
    sig = derive_signature(key, qs)
    return "%s&%s" % (qs, urlencode([("sig", sig)]))