public static String encodeToken(AuthenticationToken token) { return Base64.getEncoder() .encodeToString(AuthenticationToken.AuthenticationTokenSerializer.serialize(token)); }
/** * Converts the current object to a serialized form. The object returned from this contains a * non-destroyable version of the {@link AuthenticationToken}, so references to it should be * tightly controlled. * * @return serialized form of these credentials */ public final String serialize() { return (getPrincipal() == null ? "-" : Base64.getEncoder().encodeToString(getPrincipal().getBytes(UTF_8))) + ":" + (getToken() == null ? "-" : Base64.getEncoder().encodeToString(getToken().getClass().getName().getBytes(UTF_8))) + ":" + (getToken() == null ? "-" : Base64.getEncoder() .encodeToString(AuthenticationTokenSerializer.serialize(getToken()))); }
out.writeUTF(token.getClass().getName()); out.writeUTF( Base64.getEncoder().encodeToString(AuthenticationTokenSerializer.serialize(token))); } else { out.writeUTF(tokenFile);
} else if (null != token) { out.writeUTF(token.getClass().getName()); out.writeUTF(Base64.encodeBase64String(AuthenticationTokenSerializer.serialize(token))); } else { out.writeUTF(tokenFile);
.encodeBase64String(AuthenticationTokenSerializer.serialize(token));
conf.set(enumToConfKey(implementingClass, ConnectorInfo.TOKEN), TokenSource.INLINE.prefix() + token.getClass().getName() + ":" + Base64.encodeBase64String(AuthenticationTokenSerializer.serialize(token)));
+ Base64.encodeBase64String(AuthenticationToken.AuthenticationTokenSerializer.serialize(pt));
/** * DON'T USE THIS. No, really, don't use this. You already have an {@link AuthenticationToken} * with * {@link org.apache.accumulo.core.client.mapreduce.lib.impl.ConfiguratorBase#getAuthenticationToken(Class, Configuration)}. * You don't need to construct it yourself. * <p> * Gets the password from the configuration. WARNING: The password is stored in the Configuration * and shared with all MapReduce tasks; It is BASE64 encoded to provide a charset safe conversion * to a string, and is not intended to be secure. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @return the decoded principal's authentication token * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat. * @since 1.5.0 * @see #setConnectorInfo(Class, Configuration, String, AuthenticationToken) */ @Deprecated public static byte[] getToken(Class<?> implementingClass, Configuration conf) { return AuthenticationTokenSerializer .serialize(org.apache.accumulo.core.client.mapreduce.lib.impl.ConfiguratorBase .getAuthenticationToken(implementingClass, conf)); }
public TCredentials getCredentials() throws D4mException { TCredentials tCred; try { // DH2015: Copied from // 1.6: org.apache.accumulo.core.security.Credentials#toThrift() // 1.7: org.apache.accumulo.core.client.impl.Credentials#toThrift() // in order to create compatibility to 1.6 and 1.7, since the Credentials class moved. // This may still break in later versions because Credentials is non-public API. tCred = new TCredentials(principal, token.getClass().getName(), ByteBuffer.wrap(AuthenticationToken.AuthenticationTokenSerializer.serialize(token)), instance.getInstanceID()); if (token.isDestroyed()) throw new RuntimeException("Token has been destroyed", new AccumuloSecurityException(principal, SecurityErrorCode.TOKEN_EXPIRED)); // tCred = this.creds.toThrift(this.instance); //.create(this.conn.getUser(), this.passwordToken, this.instance.getInstanceID() ); } catch (Exception e) { log.warn("",e); throw new D4mException(e); } return tCred; }
/** * Converts the current object to the relevant thrift type. The object returned from this contains * a non-destroyable version of the {@link AuthenticationToken}, so this should be used just * before placing on the wire, and references to it should be tightly controlled. * * @param instance * client instance * @return Thrift credentials * @throws RuntimeException * if the authentication token has been destroyed (expired) */ public TCredentials toThrift(Instance instance) { TCredentials tCreds = new TCredentials(getPrincipal(), getToken().getClass().getName(), ByteBuffer.wrap(AuthenticationTokenSerializer.serialize(getToken())), instance.getInstanceID()); if (getToken().isDestroyed()) throw new RuntimeException("Token has been destroyed", new AccumuloSecurityException(getPrincipal(), SecurityErrorCode.TOKEN_EXPIRED)); return tCreds; }
/** * Converts the current object to a serialized form. The object returned from this contains a * non-destroyable version of the {@link AuthenticationToken}, so references to it should be * tightly controlled. * * @return serialized form of these credentials */ public final String serialize() { return (getPrincipal() == null ? "-" : Base64.encodeBase64String(getPrincipal().getBytes(UTF_8))) + ":" + (getToken() == null ? "-" : Base64.encodeBase64String(getToken().getClass().getName().getBytes(UTF_8))) + ":" + (getToken() == null ? "-" : Base64.encodeBase64String(AuthenticationTokenSerializer.serialize(getToken()))); }
/** * Gets the serialized token from either the configuration or the token file. * * @since 1.5.0 * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobContext)} instead. */ @Deprecated protected static byte[] getToken(JobContext context) { return AuthenticationTokenSerializer.serialize(getAuthenticationToken(context)); }
/** * Gets the serialized token from either the configuration or the token file. * * @since 1.5.0 * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobConf)} instead. */ @Deprecated protected static byte[] getToken(JobConf job) { return AuthenticationTokenSerializer.serialize(getAuthenticationToken(job)); }
/** * Gets the serialized token from either the configuration or the token file. * * @since 1.5.0 * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobContext)} instead. */ @Deprecated protected static byte[] getToken(JobContext context) { return AuthenticationToken.AuthenticationTokenSerializer .serialize(getAuthenticationToken(context)); }
conf.set(enumToConfKey(implementingClass, ConnectorInfo.TOKEN), TokenSource.INLINE.prefix() + token.getClass().getName() + ":" + Base64.getEncoder().encodeToString(AuthenticationTokenSerializer.serialize(token)));
/** * Converts the current object to the relevant thrift type. The object returned from this contains * a non-destroyable version of the {@link AuthenticationToken}, so this should be used just * before placing on the wire, and references to it should be tightly controlled. * * @param instanceID * Accumulo instance ID * @return Thrift credentials * @throws RuntimeException * if the authentication token has been destroyed (expired) */ public TCredentials toThrift(String instanceID) { TCredentials tCreds = new TCredentials(getPrincipal(), getToken().getClass().getName(), ByteBuffer.wrap(AuthenticationTokenSerializer.serialize(getToken())), instanceID); if (getToken().isDestroyed()) throw new RuntimeException("Token has been destroyed", new AccumuloSecurityException(getPrincipal(), SecurityErrorCode.TOKEN_EXPIRED)); return tCreds; }
/** * Gets the serialized token from either the configuration or the token file. * * @since 1.5.0 * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobConf)} instead. */ @Deprecated protected static byte[] getToken(JobConf job) { return AuthenticationTokenSerializer.serialize(getAuthenticationToken(job)); }
/** * Gets the serialized token from either the configuration or the token file. * * @since 1.5.0 * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobContext)} instead. */ @Deprecated protected static byte[] getToken(JobContext context) { return AuthenticationTokenSerializer.serialize(getAuthenticationToken(context)); }
/** * Gets the serialized token from either the configuration or the token file. * * @since 1.5.0 * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobContext)} instead. */ @Deprecated protected static byte[] getToken(JobContext job) { return AuthenticationToken.AuthenticationTokenSerializer.serialize(getAuthenticationToken(job)); }