/** * Make a best effort to ensure that the supplied credential is a snapshot credential (i.e. self-contained and * does not reference any external stores). <b>WARNING:</b> May produce unusual results if presented an exotic * credential that implements multiple distinct credential types at the same time, e.g. a credential that is * simultaneously a TLS certificate and a SSH key pair and a GPG key pair all at the same time... unless the * author of that credential type also provides a {@link CredentialsSnapshotTaker} that can handle such a * tripple play. * * @param credential the credential. * @param <C> the type of credential. * @return the credential or a snapshot of the credential. * @since 1.14 */ @SuppressWarnings("unchecked") public static <C extends Credentials> C snapshot(C credential) { return (C) snapshot(Credentials.class, credential); }
/** * Make a best effort to ensure that the supplied credential is a snapshot credential (i.e. self-contained and * does not reference any external stores). <b>WARNING:</b> May produce unusual results if presented an exotic * credential that implements multiple distinct credential types at the same time, e.g. a credential that is * simultaneously a TLS certificate and a SSH key pair and a GPG key pair all at the same time... unless the * author of that credential type also provides a {@link CredentialsSnapshotTaker} that can handle such a * tripple play. * * @param credential the credential. * @param <C> the type of credential. * @return the credential or a snapshot of the credential. * @since 1.14 */ @SuppressWarnings("unchecked") public static <C extends Credentials> C snapshot(C credential) { return (C) snapshot(Credentials.class, credential); }
/** {@inheritDoc} */ public void addDefaultCredentials(StandardCredentials credentials) { proxy.addDefaultCredentials(CredentialsProvider.snapshot(StandardCredentials.class, credentials)); // credentials are Serializable }
/** {@inheritDoc} */ public void setCredentials(StandardUsernameCredentials cred) { proxy.setCredentials(CredentialsProvider.snapshot(StandardUsernameCredentials.class, cred)); // credentials are Serializable }
/** {@inheritDoc} */ public void addCredentials(String url, StandardCredentials credentials) { proxy.addCredentials(url, CredentialsProvider.snapshot(StandardCredentials.class, credentials)); // credentials are Serializable }
/** * When serializing over a {@link Channel} ensure that we send a self-contained version. * * @return the object instance to write to the stream. */ private Object writeReplace() { if (/* XStream */Channel.current() == null || /* already safe to serialize */ keyStoreSource .isSnapshotSource()) { return this; } return CredentialsProvider.snapshot(this); }
private Object writeReplace() { if (/* XStream */Channel.current() == null) { return this; } if (privateKeySource == null || privateKeySource.isSnapshotSource()) { return this; } return CredentialsProvider.snapshot(this); }
/** * When serializing over a {@link Channel} ensure that we send a self-contained version. * * @return the object instance to write to the stream. */ private Object writeReplace() { if (/* XStream */Channel.current() == null || /* already safe to serialize */ keyStoreSource .isSnapshotSource()) { return this; } return CredentialsProvider.snapshot(this); }
/** * If this instance is being serialized to a remote channel, e.g., via Callable, replace it with a snapshot version. * * @return the snapshot version of this credential if it is being serialized to remote node, or self if not. */ private Object writeReplace() { if (Channel.current() == null) { return this; } if (kubeconfigSource == null || kubeconfigSource.isSnapshotSource()) { return this; } return CredentialsProvider.snapshot(this); }