public final class NativeMetaClient extends Object implements MetaClient
Modifier and Type | Class and Description |
---|---|
static class |
NativeMetaClient.Builder |
Modifier and Type | Method and Description |
---|---|
void |
askForAsset(String jsonOrUrn)
Requests the specified asset from the Metadata Server.
|
boolean |
canCreateKey(String kind) |
boolean |
canRecoveryBePerformed() |
void |
changeEmail(String newEmail) |
void |
changeName(String newName) |
void |
changePassword(String oldPassword,
String newPassword) |
void |
changesWereNotSaved()
If unable to save serials, this function must be called.
|
void |
createAccount(String email,
String name,
String password)
Does not pay attention to whether or not an account already exists.
|
protected void |
finalize() |
String |
getArchiveDecryptionPassword(String jsonOrUrn)
Given asset information as described below, extracts a decryption password.
|
EncryptionInfo |
getArchiveEncryptionInfo(String jsonOrUrn,
String password)
Deprecated.
|
String |
getEntitlement(String name,
String defaultValue) |
Logger |
getLogger() |
ManagedAesKey |
getManagedAesKey(String serialized) |
List<SingleAssetManager> |
getManagedAesKeys() |
Set<Notification> |
getNotifications() |
int |
getSyncInterval() |
List<KnownUser> |
getXPIDs() |
boolean |
isAccountManaged(String email)
Query server and find out if this email is a managed account.
|
boolean |
isDeviceAllowed() |
boolean |
isLicensed()
This will perform a network call.
|
boolean |
isLoggedIn() |
boolean |
isSatellite()
Is not valid until a previous call to PKMeta::checkDomain() in native code which happens during typical login flows or
a restore from serialized state.
|
void |
login(String emailWithHost,
String password) |
void |
loginImplicitAccount()
Performs a login using a system user.
|
void |
loginManagedAccount(String emailWithHost,
String password) |
void |
logout() |
List<KnownUser> |
lookupUsers(String... userEmails)
Asks the server for user information for the provided email addresses.
|
void |
migrate(String username,
String password,
String accountPassword,
boolean mfaExpected) |
String |
recoverPassword(String code,
boolean mfaExpected,
String cipher) |
void |
requestAccess(String serialized) |
void |
requestEmailVerification() |
void |
requestRecoveryEmail(String email) |
void |
respondToNotification(String urn,
String action) |
void |
restoreAll(Map<String,String> serials) |
Map<String,String> |
serializeAll()
It is assumed that all data after this call are successfully transformed.
|
void |
switchToCentral(String prefix) |
boolean |
switchToDomain(String domainOrEmail)
May overwrite any previous information passed to
MetaClient.switchToCentral(String) . |
void |
sync() |
EncryptionInfo |
wrapSessionKeyWithSmartkey(String smartkeyUrn)
Generates a new 256 bit session key and wraps it for secure storage and future retrieval.
|
EncryptionInfo |
wrapSessionKeyWithSmartkey(String smartkeyUrn,
String sessionKey)
Expands the existing session key to 256 bits and wraps it for secure storage and future retrieval.
|
public void restoreAll(Map<String,String> serials) throws MetaClientException
restoreAll
in interface MetaClient
MetaClientException
- If the data being restored are invalid. Invalid means that there are a different number than expected or that any are different from when we last saw them.@Nonnull public Map<String,String> serializeAll() throws MetaClientException
MetaClient
MetaClient.changesWereNotSaved()
serializeAll
in interface MetaClient
null
.MetaClientException
public void changesWereNotSaved()
MetaClient
changesWereNotSaved
in interface MetaClient
public void requestEmailVerification()
requestEmailVerification
in interface MetaClient
public void sync() throws MetaClientException
sync
in interface MetaClient
MetaClientException
public void askForAsset(String jsonOrUrn) throws MetaClientException
MetaClient
askForAsset
in interface MetaClient
jsonOrUrn
- Whenever possible, the full asset JSON should be provided. The JSON will include all
information to correctly find an asset. If only the URN is provided, the asset may not be found.MetaClientException
- with a MetaClientException.category
of
MetaClientException.CATEGORY_INTERNAL
if the json
provided is in an unrecognized format. Other variations of the exception may be thrown as well.@Nonnull public String getArchiveDecryptionPassword(String jsonOrUrn) throws MetaClientException
MetaClient
getArchiveDecryptionPassword
in interface MetaClient
jsonOrUrn
- Whenever possible, the full asset JSON should be provided. The JSON will include all
information to correctly find an asset. If only the URN is provided, the asset may not be found.MetaClientException
- with a MetaClientException.category
of
MetaClientException.CATEGORY_INTERNAL
if the json
provided is in an unrecognized format, or with MetaClientException.CATEGORY_NOT_FOUND
if the password cannot be
found. Other variations of the exception may be thrown as well.@Nonnull @Deprecated public EncryptionInfo getArchiveEncryptionInfo(@Nullable String jsonOrUrn, @Nullable String password) throws MetaClientException
MetaClient
getArchiveEncryptionInfo
in interface MetaClient
jsonOrUrn
- optional. Should be null
if no asset is being used.password
- optional. Should be null
if no password is being used.EncryptionInfo.json
will be null
if no asset is being used.
EncryptionInfo.password
will always be valid.MetaClientException
@Nonnull public List<KnownUser> getXPIDs()
getXPIDs
in interface MetaClient
@Nonnull public List<KnownUser> lookupUsers(String... userEmails) throws MetaClientException
MetaClient
lookupUsers
in interface MetaClient
MetaClientException
public boolean isDeviceAllowed()
isDeviceAllowed
in interface MetaClient
public boolean isLicensed() throws MetaClientException
MetaClient
isLicensed
in interface MetaClient
true
if the current user is able to acquire a license; otherwise, false
MetaClientException
- if there was any non-standard problem. Think network, signature, etc.public boolean isSatellite()
MetaClient
isSatellite
in interface MetaClient
true
if this instance is known to be communicating with a SMDS rather than a CMDS, otherwise false
public boolean switchToDomain(String domainOrEmail) throws MetaClientException
MetaClient
MetaClient.switchToCentral(String)
. Performs
network IO.switchToDomain
in interface MetaClient
domainOrEmail
- Domain name registered with CMDS or the email address of the current user,
from which the domain will be deduced.true
if now talking to a SMDS. Otherwise, false
.MetaClientException
- primarily for network reasons, but could be others as well.
Best to display to the user.public boolean isAccountManaged(String email) throws MetaClientException
MetaClient
isAccountManaged
in interface MetaClient
email
- of the current usertrue
if the account is managed, otherwise, false
.MetaClientException
- primarily for network reasons, but could be others as well. Best to display to the user.
With MetaClientException.CATEGORY_MIGRATION_REQUIRED
if needing to migrate.public void switchToCentral(String prefix)
switchToCentral
in interface MetaClient
prefix
- The base URL of the central server. For example, https://vcs.pkware.com/mds
.public boolean isLoggedIn()
isLoggedIn
in interface MetaClient
public int getSyncInterval()
getSyncInterval
in interface MetaClient
@Nonnull public String getEntitlement(String name, @Nullable String defaultValue)
getEntitlement
in interface MetaClient
name
- of the entitlementdefaultValue
if the entitlement is not foundpublic void changeEmail(String newEmail) throws MetaClientException
changeEmail
in interface MetaClient
MetaClientException
public void changeName(String newName) throws MetaClientException
changeName
in interface MetaClient
MetaClientException
public void changePassword(String oldPassword, String newPassword) throws MetaClientException
changePassword
in interface MetaClient
MetaClientException
public void respondToNotification(String urn, String action) throws MetaClientException
respondToNotification
in interface MetaClient
MetaClientException
@Nonnull public Set<Notification> getNotifications()
getNotifications
in interface MetaClient
public boolean canCreateKey(String kind)
canCreateKey
in interface MetaClient
@Nonnull public List<SingleAssetManager> getManagedAesKeys()
getManagedAesKeys
in interface MetaClient
@Nonnull public ManagedAesKey getManagedAesKey(String serialized) throws MetaClientException
getManagedAesKey
in interface MetaClient
MetaClientException
- with MetaClientException.category
of MetaClientException.CATEGORY_UPGRADE
if the serialized content cannot be parsed. Also with other categories for other reasons.public void logout()
logout
in interface MetaClient
public void login(String emailWithHost, String password) throws MetaClientException
login
in interface MetaClient
MetaClientException
public void loginManagedAccount(String emailWithHost, String password) throws MetaClientException
loginManagedAccount
in interface MetaClient
MetaClientException
public void loginImplicitAccount()
MetaClient
kinit
or a similar utility is used.
When this login method is used, MetaClient.login(String, String)
and MetaClient.loginManagedAccount(String, String)
must not be used. Additionally, a custom server URL must be provided using
NativeMetaClient.Builder.server(String)
.
loginImplicitAccount
in interface MetaClient
MetaClient.loginManagedAccount(String, String)
,
MetaClient.login(String, String)
public void migrate(String username, String password, String accountPassword, boolean mfaExpected) throws MetaClientException
migrate
in interface MetaClient
accountPassword
- typically from Active DirectoryMetaClientException
public void createAccount(String email, @Nullable String name, String password) throws MetaClientException
MetaClient
createAccount
in interface MetaClient
name
- Can be null
in which case this user won't have a nameMetaClientException
- if account creation failspublic void requestRecoveryEmail(String email) throws MetaClientException
requestRecoveryEmail
in interface MetaClient
MetaClientException
@Nonnull public String recoverPassword(String code, boolean mfaExpected, @Nullable String cipher) throws MetaClientException
recoverPassword
in interface MetaClient
MetaClientException
public boolean canRecoveryBePerformed()
canRecoveryBePerformed
in interface MetaClient
public void requestAccess(String serialized) throws MetaClientException
requestAccess
in interface MetaClient
MetaClientException
- with MetaClientException.category
of MetaClientException.CATEGORY_UPGRADE
if the serialized content cannot be parsed. May also happen as a results of network problems and other reasons@Nonnull public Logger getLogger()
getLogger
in interface MetaClient
@Nonnull public EncryptionInfo wrapSessionKeyWithSmartkey(String smartkeyUrn, @Nullable String sessionKey)
MetaClient
wrapSessionKeyWithSmartkey
in interface MetaClient
smartkeyUrn
- of a locally held keysessionKey
- may be null
or empty@Nonnull public EncryptionInfo wrapSessionKeyWithSmartkey(String smartkeyUrn)
MetaClient
wrapSessionKeyWithSmartkey
in interface MetaClient
smartkeyUrn
- of a locally held key