Approve or reject a license

@param licenseId
@param approve
@throws GrapesCommunicationException
@throws javax.naming.AuthenticationException
504473
public void approveLicense(final String licenseId, final Boolean approve, final String user, final String password) throws GrapesCommunicationException, AuthenticationException{
        final Client client = getClient(user, password);
        final WebResource resource = client.resource(serverURL).path(RequestUtils.getLicensePath(licenseId));
        final ClientResponse response = resource.queryParam(ServerAPI.APPROVED_PARAM, approve.toString()).post(ClientResponse.class);

        client.destroy();
        if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
            final String message = "Failed to approve license " + licenseId;
            if(LOG.isErrorEnabled()) {
                LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
            }
            throw new GrapesCommunicationException(message, response.getStatus());
        }
    }
564470
public Object displayLicenseFile(InputStream licenseFile, CommandConsole commandConsole) {
        Object e = LicenseUtility.class;
        if (licenseFile != null) {
            e = showLicenseFile(licenseFile, commandConsole);
        }
        if (e != null) {
            commandConsole.printErrorMessage(CommandUtils.getMessage("LICENSE_NOT_FOUND"));
        }
        return e;
    }
1248481
private boolean isValid(final Map<String, String> properties) {

		if (!licensePresent) {
			return false;
		}


		final SimpleDateFormat format = new SimpleDateFormat(DatePattern);
		final String src              = collectLicenseFieldsForSignature(properties);
		final String name             = properties.get(NameKey);
		final String key              = properties.get(SignatureKey);
		final String hostId           = properties.get(MachineKey);
		final String thisHostId       = createHash();
		final String edition          = properties.get(EditionKey);
		final String modules          = properties.get(ModulesKey);
		final String dateString       = properties.get(DateKey);
		final String startDateString  = properties.get(StartKey);
		final String endDateString    = properties.get(EndKey);
		final String serversString    = properties.get(ServersKey);
		final String usersString      = properties.get(UsersKey); // unused (cannot be verified here)
		final Date now                = new Date();

		if (StringUtils.isEmpty(key)) {

			logger.error("Unable to read key from license file.");
			return false;
		}

		startDate = parseDate(startDateString);
		endDate   = parseDate(endDateString);

		try {

			final byte[] data      = src.getBytes(CharSet);
			final Signature signer = Signature.getInstance(SignatureAlgorithm);
			final byte[] signature = Hex.decodeHex(key.toCharArray());

			signer.initVerify(certificate);
			signer.update(data);

			if (!signer.verify(signature)) {

				logger.error("License signature verification failed, license is not valid.");
				return false;
			}

		} catch (Throwable t) {

			logger.error("Unable to verify license.", t);
			return false;
		}

		if (StringUtils.isEmpty(name)) {

			logger.error("License file doesn't contain licensee name.");
			return false;
		}

		if (StringUtils.isEmpty(edition)) {

			logger.error("License file doesn't contain edition.");
			return false;
		}

		if (StringUtils.isEmpty(modules)) {

			logger.error("License file doesn't contain modules.");
			return false;
		}

		if (StringUtils.isEmpty(hostId)) {

			logger.error("License file doesn't contain host ID.");
			return false;
		}

		if (StringUtils.isEmpty(dateString)) {

			logger.error("License file doesn't contain license date.");
			return false;
		}

		if (StringUtils.isEmpty(startDateString)) {

			logger.error("License file doesn't contain start date.");
			return false;
		}

		if (StringUtils.isEmpty(endDateString)) {

			logger.error("License file doesn't contain end date.");
			return false;
		}

		// verify host ID
		if (!thisHostId.equals(hostId) && !"*".equals(hostId)) {

			logger.error("Host ID found in license ({}) file does not match current host ID.", hostId);
			return false;
		}

		if ("*".equals(hostId)) {

			// check volume license against server addresses
			if (StringUtils.isNotBlank(serversString)) {

				// send HostID to server
				properties.put(HostIdKey, thisHostId);

				return checkVolumeLicense(properties, serversString);
			}

			final Calendar issuedAtPlusOneMonth = GregorianCalendar.getInstance();
			final Calendar cal                  = GregorianCalendar.getInstance();

			// set issuedAt to license date plus one month
			issuedAtPlusOneMonth.setTime(parseDate(dateString));
			issuedAtPlusOneMonth.add(Calendar.MONTH, 1);

			// check that the license file was issued not more than one month ago
			if (cal.after(issuedAtPlusOneMonth)) {

				logger.error("Development license found in license file is not valid any more, license period ended {}.", format.format(issuedAtPlusOneMonth.getTime()));
				return false;
			}
		}

		// verify that the license is valid for the current date
		if (startDate != null && now.before(startDate) && !now.equals(startDate)) {

			logger.error("License found in license file is not yet valid, license period starts {}.", format.format(startDate.getTime()));
			return false;
		}

		// verify that the license is valid for the current date
		if (licenseExpired()) {

			logger.error("License found in license file is not valid any more, license period ended {}.", format.format(endDate.getTime()));
			return false;
		}

		return true;
	}
479402
public void write(License license, IOFormat format) throws IOException {
        switch (format) {
            case BINARY:
                os.write(license.serialized());
                return;
            case BASE64:
                os.write(Base64.getEncoder().encode(license.serialized()));
                return;
            case STRING:
                os.write(license.toString().getBytes(StandardCharsets.UTF_8));
                return;
        }
        throw new IllegalArgumentException("License format " + format + " is unknown");
    }
769492
public GitlabMergeRequestApprovals setMergeRequestApprovers(GitlabMergeRequest mr,
                                                                Collection<Integer> userApproverIds,
                                                                Collection<Integer> groupApproverIds) throws IOException {
        String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(mr.getProjectId()) +
                GitlabMergeRequest.URL + "/" + mr.getIid() + GitlabMergeRequestApprovals.APPROVERS_URL;
        return put()
            .with("approver_ids", userApproverIds)
            .with("approver_group_ids", groupApproverIds)
            .to(tailUrl, GitlabMergeRequestApprovals.class);
    }
1187555
public static sdx_license apply(nitro_service client) throws Exception
	{
		sdx_license resource = new sdx_license();
		return ((sdx_license[]) resource.perform_operation(client, "apply"))[0];
	}
404672
def license(self, license):
        
        allowed_values = ["Public Domain", "PDDL", "CC-0", "CC-BY", "ODC-BY", "CC-BY-SA", "ODC-ODbL", "CC BY-NC", "CC BY-NC-SA", "Other"]
        if license not in allowed_values:
            raise ValueError(
                "Invalid value for `license` ({0}), must be one of {1}"
                .format(license, allowed_values)
            )

        self._license = license
223981
public void setRevocationURL(final String url) {
        license.add(Feature.Create.stringFeature(REVOCATION_URL, url));
    }
219804
function onAccessApproved(sourceId) {

        pending = false;
        
        // if "cancel" button is clicked
        if(!sourceId || !sourceId.length) {
            return port.postMessage('PermissionDeniedError');
        }
        
        // "ok" button is clicked; share "sourceId" with the
        // content-script which will forward it to the webpage
        port.postMessage({
            chromeMediaSourceId: sourceId
        });
    }
617278
public void setLicenseRules(java.util.Collection<String> licenseRules) {
        if (licenseRules == null) {
            this.licenseRules = null;
            return;
        }

        this.licenseRules = new java.util.ArrayList<String>(licenseRules);
    }
805689
def update_license(license_id, **kwargs):
    
    updated_license = pnc_api.licenses.get_specific(id=license_id).content

    for key, value in iteritems(kwargs):
        if value:
            setattr(updated_license, key, value)

    response = utils.checked_api_call(
        pnc_api.licenses,
        'update',
        id=int(license_id),
        body=updated_license)
    if response:
        return utils.format_json(response.content)
1221571
public void setLicenseType(com.google.api.ads.admanager.axis.v201811.LicenseType licenseType) {
        this.licenseType = licenseType;
    }
1138944
public void setLicense(String photoId, int licenseId) throws FlickrException {
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("method", METHOD_SET_LICENSE);
        parameters.put("photo_id", photoId);
        parameters.put("license_id", Integer.toString(licenseId));

        // Note: This method requires an HTTP POST request.
        Response response = transportAPI.post(transportAPI.getPath(), parameters, apiKey, sharedSecret);
        if (response.isError()) {
            throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
        }
        // This method has no specific response - It returns an empty sucess response if it completes without error.

    }
706453
private void setIssuerUniqueId(Object val) throws CertificateException {
        if (version.compare(CertificateVersion.V2) < 0) {
            throw new CertificateException("Invalid version");
        }
        if (!(val instanceof UniqueIdentity)) {
            throw new CertificateException(
                             "IssuerUniqueId class type invalid.");
        }
        issuerUniqueId = (UniqueIdentity)val;
    }
913236
func Approve(id string, params *stripe.ReviewApproveParams) (*stripe.Review, error) {
	return getC().Approve(id, params)
}
189001
def update
      @script_licence.user_id = current_user.id
      @script_licence.org_id = current_user.org_id
      if @script_licence.update(script_licence_params)
        redirect_to script_licences_url, notice: 'Licence was successfully updated.'
        else
          render :edit
      end
    end
322556
@POST
    @Path("/{gavc}" + ServerAPI.GET_LICENSES)
    public Response addLicense(@Auth final DbCredential credential,
                               @PathParam("gavc") final String gavc,
                               @QueryParam(ServerAPI.LICENSE_ID_PARAM) final String licenseId){
        if(!credential.getRoles().contains(AvailableRoles.DATA_UPDATER) &&
                !credential.getRoles().contains(AvailableRoles.LICENSE_SETTER)){
            throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build());
        }

        if(LOG.isInfoEnabled()) {
            LOG.info(String.format("Got a add license request [%s]", gavc));
        }

        if(licenseId == null){
            return Response.serverError().status(HttpStatus.NOT_ACCEPTABLE_406).build();
        }

        getArtifactHandler().addLicenseToArtifact(gavc, licenseId);
        cacheUtils.clear(CacheName.PROMOTION_REPORTS);

        return Response.ok("done").build();
    }