returns application if the masterSecret is valid for the request
PushApplicationEntity
358825
private Variant loadVariantWhenAuthorized(final HttpServletRequest request) {
        // extract the pushApplicationID and its secret from the HTTP Basic
        // header:
        final String[] credentials = HttpBasicHelper.extractUsernameAndPasswordFromBasicHeader(request);
        final String variantID = credentials[0];
        final String secret = credentials[1];

        final Variant variant = genericVariantService.findByVariantID(variantID);
        if (variant != null && variant.getSecret().equals(secret)) {
            return variant;
        }

        // unauthorized...
        return null;
    }
880305
private String getPayLoad(Key key, Application app) {
        if (app == null) {
            return EMPTY_PAYLOAD;
        }

        EncoderWrapper encoderWrapper = serverCodecs.getEncoder(key.getType(), key.getEurekaAccept());
        try {
            return encoderWrapper.encode(app);
        } catch (Exception e) {
            logger.error("Failed to encode the payload for application {}", app.getName(), e);
            return "";
        }
    }
854822
@Override
    public boolean canEdit(ProjectEntity entity, SecurityService securityService) {
        switch (entity.getProjectEntityType()) {
            case BUILD:
                return securityService.isProjectFunctionGranted(entity, BuildCreate.class);
            case PROMOTION_RUN:
                return securityService.isProjectFunctionGranted(entity, PromotionRunCreate.class);
            case VALIDATION_RUN:
                return securityService.isProjectFunctionGranted(entity, ValidationRunCreate.class);
            default:
                throw new PropertyUnsupportedEntityTypeException(getClass().getName(), entity.getProjectEntityType());
        }
    }
234066
public boolean isValidEntityObject(Object entity, EntityMetadata metadata)
    {
        if (entity == null)
        {
            log.error("Entity to be persisted must not be null, operation failed");
            return false;
        }

        Object id = PropertyAccessorHelper.getId(entity, metadata);
        if (id == null)
        {
            log.error("Entity to be persisted can't have Primary key set to null.");
            throw new IllegalArgumentException("Entity to be persisted can't have Primary key set to null.");
            // return false;
        }
        return true;
    }
1046888
function getAppContextFromArgv(apps) {
  return Promise.try(function() {
    return _.find(apps, function(app) {
      return app.name === argv.payload[0];
    });
  });
}
291317
private boolean validateAppSignatureForPackage(Context context, String packageName) {

        PackageInfo packageInfo;
        try {
            packageInfo = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
        } catch (NameNotFoundException e) {
            return false;
        }

        for (Signature signature : packageInfo.signatures) {
            if (signature.toCharsString().equals(FB_APP_SIGNATURE)) {
                return true;
            }
        }
        return false;
    }
791644
def Get(self):
    """"""

    args = user_pb2.ApiGetClientApprovalArgs(
        client_id=self.client_id,
        approval_id=self.approval_id,
        username=self.username)
    result = self._context.SendRequest("GetClientApproval", args)
    return ClientApproval(
        data=result, username=self._context.username, context=self._context)
1327974
@Override
    public Application onApplicationInit(Application app, JaxRsModuleMetaData metaData) {

        Class<?> clazz = app.getClass();

        if (!shouldHandle(clazz, true)) {
            return null;
        }
        Application newApp = null;

        ManagedObject<?> mo = getClassFromManagedObject(clazz);
        metaData.setManagedAppRef(mo);

        if (mo != null) {
            newApp = (Application) (mo.getObject());
        }

        if (newApp == null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "App: app is null from CDI , get app from rs for " + app.getClass().getName());
            }
            return app;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "App: get app from CDI " + app.getClass().getName());
        }
        return newApp;
    }
751952
def validate(self):
        """"""

        validate_url = "https://api.pushover.net/1/users/validate.json"

        payload = {
            'token': self.api_token,
            'user': self.user,
        }

        return requests.post(validate_url, data=payload)
1052675
private String getPayLoad(Key key, Applications apps) {
        EncoderWrapper encoderWrapper = serverCodecs.getEncoder(key.getType(), key.getEurekaAccept());
        String result;
        try {
            result = encoderWrapper.encode(apps);
        } catch (Exception e) {
            logger.error("Failed to encode the payload for all apps", e);
            return "";
        }
        if(logger.isDebugEnabled()) {
            logger.debug("New application cache entry {} with apps hashcode {}", key.toStringCompact(), apps.getAppsHashCode());
        }
        return result;
    }
737336
def _get_entity(partition_key, row_key, select, accept):
    '''
    
    '''
    _validate_not_none('partition_key', partition_key)
    _validate_not_none('row_key', row_key)
    _validate_not_none('accept', accept)
    request = HTTPRequest()
    request.method = 'GET'
    request.headers = [('Accept', _to_str(accept))]
    request.query = [('$select', _to_str(select))]

    return request
73663
def getApplicationsThatSupportMimeType(self, pchMimeType, pchAppKeysThatSupportBuffer, unAppKeysThatSupportBuffer):
        """"""

        fn = self.function_table.getApplicationsThatSupportMimeType
        result = fn(pchMimeType, pchAppKeysThatSupportBuffer, unAppKeysThatSupportBuffer)
        return result
1224877
@Override
    public boolean hasAppManagedPC(Collection<InjectionBinding<?>> injectionBindings,
                                   String ejbName,
                                   Set<String> persistenceRefNames)
    {
        return JPAExEntityManager.hasAppManagedPC(injectionBindings, ejbName, persistenceRefNames); // F743-30682
    }
1170566
public static Response getCreateResponse(App app, String type, InputStream is) {
		try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
				RestUtils.class, "crud", "create")) {
			ParaObject content;
			Response entityRes = getEntity(is, Map.class);
			if (entityRes.getStatusInfo() == Response.Status.OK) {
				Map<String, Object> newContent = (Map<String, Object>) entityRes.getEntity();
				String declaredType = (String) newContent.get(Config._TYPE);
				if (!StringUtils.isBlank(type) && (StringUtils.isBlank(declaredType) || !type.startsWith(declaredType))) {
					newContent.put(Config._TYPE, type);
				}
				content = ParaObjectUtils.setAnnotatedFields(newContent);
				if (app != null && content != null && isNotAnApp(type)) {
					warnIfUserTypeDetected(type);
					content.setAppid(app.getAppIdentifier());
					setCreatorid(app, content);
					int typesCount = app.getDatatypes().size();
					app.addDatatypes(content);
					// The reason why we do two validation passes is because we want to return
					// the errors through the API and notify the end user.
					// This is the primary validation pass (validates not only core POJOS but also user defined objects).
					String[] errors = validateObject(app, content);
					if (errors.length == 0) {
						// Secondary validation pass called here. Object is validated again before being created
						// See: IndexAndCacheAspect.java
						String id = content.create();
						if (id != null) {
							// new type added so update app object
							if (typesCount < app.getDatatypes().size()) {
								app.update();
							}
							return Response.created(URI.create(Utils.urlEncode(content.getObjectURI()))).
									entity(content).build();
						}
					}
					return getStatusResponse(Response.Status.BAD_REQUEST, errors);
				}
				return getStatusResponse(Response.Status.BAD_REQUEST, "Failed to create object.");
			}
			return entityRes;
		}
	}
426926
public Maybe<ApplicationInfo> getApplicationInfo(String clientId) {
        return db.findClientCredentials(clientId).map(creds -> {
            ApplicationInfo appInfo = null;
            if (creds != null) {
                appInfo = ApplicationInfo.loadFromClientCredentials(creds);
            }
            return appInfo;
        });
    }
633091
def from_current(cls):
        
        if properties.application_id is None:
            raise context.ValueError("Not running inside a container")

        return cls(properties.appmaster_address,
                   properties.application_id,
                   security=Security.from_default())
970324
public static boolean verify(String appId, String appSecretKey, byte[] body, HttpServletRequest request)
            throws IOException {
        HmacSignatureBuilder builder = new HmacSignatureBuilder();

        String signitSignature = request.getHeader("X-Signit-Signature");
        builder.scheme(request.getHeader("X-Signit-Scheme"))
                .apiKey(appId)
                .apiSecret(appSecretKey.getBytes())
                .method(request.getMethod()
                        .toUpperCase())
                .payload(body)
                .contentType(request.getContentType())
                .host(Validator.isEmpty(request.getHeader("X-Signit-Host")) ? "" : request.getHeader("X-Signit-Host"))
                .resource(Validator.isEmpty(request.getHeader("X-Signit-Resource")) ? ""
                        : request.getHeader("X-Signit-Resource"))
                .nonce(Validator.isEmpty(request.getHeader("X-Signit-Nonce")) ? ""
                        : request.getHeader("X-Signit-Nonce"))
                .date(Validator.isEmpty(request.getHeader("X-Signit-Date")) ? "" : request.getHeader("X-Signit-Date"));
        String selfBuiltHmac = builder.getDefaultAlgorithm() + " " + appId + ":" + builder.buildAsBase64();
        return selfBuiltHmac.equals(signitSignature);
    }