List of usage examples for org.apache.hadoop.security Credentials getSecretKey
public byte[] getSecretKey(Text alias)
From source file:org.apache.hive.storage.jdbc.dao.GenericJdbcDatabaseAccessor.java
License:Apache License
protected Properties getConnectionPoolProperties(Configuration conf) throws Exception { // Create the default properties object Properties dbProperties = getDefaultDBCPProperties(); // override with user defined properties Map<String, String> userProperties = conf.getValByRegex(DBCP_CONFIG_PREFIX + "\\.*"); if ((userProperties != null) && (!userProperties.isEmpty())) { for (Entry<String, String> entry : userProperties.entrySet()) { dbProperties.put(entry.getKey().replaceFirst(DBCP_CONFIG_PREFIX + "\\.", ""), entry.getValue()); }//from w w w . j ava 2 s. c o m } // handle password Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials(); if (credentials.getSecretKey(DBCP_PWD) != null) { LOGGER.info("found token in credentials"); dbProperties.put(DBCP_PWD, new String(credentials.getSecretKey(DBCP_PWD))); } // essential properties that shouldn't be overridden by users dbProperties.put("url", conf.get(JdbcStorageConfig.JDBC_URL.getPropertyName())); dbProperties.put("driverClassName", conf.get(JdbcStorageConfig.JDBC_DRIVER_CLASS.getPropertyName())); dbProperties.put("type", "javax.sql.DataSource"); return dbProperties; }
From source file:org.apache.tez.common.security.TokenCache.java
License:Apache License
/** * auxiliary method to get user's secret keys.. * @param alias// w ww .j av a 2 s.com * @return secret key from the storage */ public static byte[] getSecretKey(Credentials credentials, Text alias) { if (credentials == null) return null; return credentials.getSecretKey(alias); }
From source file:org.springframework.yarn.examples.XdContainer.java
License:Apache License
@Override protected void runInternal() { log.info("XdContainer internal run starting, setting up XD container launcher"); log.info("Using xd.home=" + getEnvironment("xd.home")); log.info("Using syarn.cg.group=" + getEnvironment("syarn.cg.group")); // setup needed options ContainerOptions options = new ContainerOptions(); AbstractOptions.setXDHome(getEnvironment("xd.home")); AbstractOptions.setXDTransport(Transport.redis); // do the xd internal container launch log.info("XdContainer launch"); ContainerLauncher launcher = context.getBean(ContainerLauncher.class); Container container = launcher.launch(options); log.info("XdContainer launched id=" + container.getId() + " jvm=" + container.getJvmName()); HeartbeatAppmasterServiceClient serviceClient = context.getBean(HeartbeatAppmasterServiceClient.class); Credentials credentials = getCredentials(); String sessionId = new String(credentials.getSecretKey(new Text(YarnSystemConstants.SYARN_SEC_SESSIONID))); serviceClient.setSessionId(sessionId); // set empty node info order to enable heartbeats serviceClient.setNodeInfo(new NodeInfo()); }