-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Endpoint][Admin] Malware user notification is a p…
…latinum tiered feature (#82894)
- Loading branch information
Showing
8 changed files
with
169 additions
and
20 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
x-pack/plugins/security_solution/common/license/license.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { Observable, Subscription } from 'rxjs'; | ||
import { ILicense } from '../../../licensing/common/types'; | ||
|
||
// Generic license service class that works with the license observable | ||
// Both server and client plugins instancates a singleton version of this class | ||
export class LicenseService { | ||
private observable: Observable<ILicense> | null = null; | ||
private subscription: Subscription | null = null; | ||
private licenseInformation: ILicense | null = null; | ||
|
||
private updateInformation(licenseInformation: ILicense) { | ||
this.licenseInformation = licenseInformation; | ||
} | ||
|
||
public start(license$: Observable<ILicense>) { | ||
this.observable = license$; | ||
this.subscription = this.observable.subscribe(this.updateInformation.bind(this)); | ||
} | ||
|
||
public stop() { | ||
if (this.subscription) { | ||
this.subscription.unsubscribe(); | ||
} | ||
} | ||
|
||
public getLicenseInformation() { | ||
return this.licenseInformation; | ||
} | ||
|
||
public getLicenseInformation$() { | ||
return this.observable; | ||
} | ||
|
||
public isGoldPlus() { | ||
return ( | ||
this.licenseInformation?.isAvailable && | ||
this.licenseInformation?.isActive && | ||
this.licenseInformation?.hasAtLeast('gold') | ||
); | ||
} | ||
public isPlatinumPlus() { | ||
return ( | ||
this.licenseInformation?.isAvailable && | ||
this.licenseInformation?.isActive && | ||
this.licenseInformation?.hasAtLeast('platinum') | ||
); | ||
} | ||
public isEnterprise() { | ||
return ( | ||
this.licenseInformation?.isAvailable && | ||
this.licenseInformation?.isActive && | ||
this.licenseInformation?.hasAtLeast('enterprise') | ||
); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
x-pack/plugins/security_solution/public/common/hooks/use_license.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { LicenseService } from '../../../common/license/license'; | ||
|
||
export const licenseService = new LicenseService(); | ||
|
||
export function useLicense() { | ||
return licenseService; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
x-pack/plugins/security_solution/server/lib/license/license.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { LicenseService } from '../../../common/license/license'; | ||
|
||
export const licenseService = new LicenseService(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters