Class SecretKeyAccess
- java.lang.Object
-
- com.google.crypto.tink.SecretKeyAccess
-
@CheckReturnValue @Immutable public final class SecretKeyAccess extends java.lang.ObjectRepresents access to secret key material.Tink restricts access to secret key material, and users who require such access need to have an object of the class
SecretKeyAccessto do this. For example, a function that outputs individiual key bytes might look like this:class HmacKey { ... public byte[] getKeyMaterial(SecretKeyAccess access) { checkNotNull(access); return keyMaterial; } }Users who want to callgetKeyMaterialthen need to get aSecretKeyAccessobject viaInsecureSecretKeyAccess.get().
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SecretKeyAccessrequireAccess(SecretKeyAccess access)Throws an exception if the passed inSecretKeyAccessis null, otherwise returns it.
-
-
-
Method Detail
-
requireAccess
@CanIgnoreReturnValue public static SecretKeyAccess requireAccess(@Nullable SecretKeyAccess access) throws java.security.GeneralSecurityException
Throws an exception if the passed inSecretKeyAccessis null, otherwise returns it.Note: Tink has two types of APIs, some which take a nullable
SecretKeyAccess, and some which take aSecretKeyAccesswithout annotation. When an API takes a nullableSecretKeyAccess, this indicates that proper usage may call it withnull, hence we typically want to throw a checked exception andrequireAccesshere is appropriate. Conversely, if an API takes an unannotatedSecretKeyAccess, this indicates that the API always requires a non-null object. In this case, using it with null warrants should usually throw a null pointer exception (and one does not want to userequireAccess).- Throws:
java.security.GeneralSecurityException
-
-