List of usage examples for org.apache.hadoop.security.token Token encodeToUrlString
public String encodeToUrlString() throws IOException
From source file:azkaban.security.HadoopSecurityManager_H_1_0.java
License:Apache License
private void cancelHiveToken(final Token<? extends TokenIdentifier> t, String userToProxy) throws HadoopSecurityManagerException { try {// ww w . j a v a 2 s. co m HiveConf hiveConf = new HiveConf(); HiveMetaStoreClient hiveClient = new HiveMetaStoreClient(hiveConf); hiveClient.cancelDelegationToken(t.encodeToUrlString()); } catch (Exception e) { e.printStackTrace(); throw new HadoopSecurityManagerException("Failed to cancel Token. " + e.getMessage() + e.getCause()); } }
From source file:azkaban.security.HadoopSecurityManager_H_2_0.java
License:Apache License
private void cancelHiveToken(final Token<? extends TokenIdentifier> t, String userToProxy) throws HadoopSecurityManagerException { try {//from w w w .ja v a 2 s . c o m HiveConf hiveConf = new HiveConf(); HiveMetaStoreClient hiveClient = new HiveMetaStoreClient(hiveConf); hiveClient.cancelDelegationToken(t.encodeToUrlString()); } catch (Exception e) { throw new HadoopSecurityManagerException("Failed to cancel Token. " + e.getMessage() + e.getCause(), e); } }
From source file:com.bigstep.datalake.DLFileSystem.java
License:Apache License
private Param<?, ?>[] getAuthParameters(final HttpOpParam.Op op) throws IOException { List<Param<?, ?>> authParams = Lists.newArrayList(); // Skip adding delegation token for token operations because these // operations require authentication. Token<?> token = null; if (!op.getRequireAuth()) { token = getDelegationToken();//from ww w . j av a 2s.co m } if (token != null) { authParams.add(new DelegationParam(token.encodeToUrlString())); } else { authParams.add(new UserParam(kerberosIdentity.getPrincipalShortName())); } return authParams.toArray(new Param<?, ?>[0]); }
From source file:com.bigstep.datalake.DLFileSystem.java
License:Apache License
@Override public synchronized long renewDelegationToken(final Token<?> token) throws IOException { final HttpOpParam.Op op = PutOpParam.Op.RENEWDELEGATIONTOKEN; return new FsPathResponseRunner<Long>(op, null, new TokenArgumentParam(token.encodeToUrlString())) { @Override/* www .j ava2s. c o m*/ Long decodeResponse(Map<?, ?> json) throws IOException { return ((Number) json.get("long")).longValue(); } }.run(); }
From source file:com.bigstep.datalake.DLFileSystem.java
License:Apache License
@Override public synchronized void cancelDelegationToken(final Token<?> token) throws IOException { final HttpOpParam.Op op = PutOpParam.Op.CANCELDELEGATIONTOKEN; new FsPathRunner(op, null, new TokenArgumentParam(token.encodeToUrlString())).run(); }
From source file:com.bigstep.datalake.JsonUtil.java
License:Apache License
private static Map<String, Object> toJsonMap(final Token<? extends TokenIdentifier> token) throws IOException { if (token == null) { return null; }/*from w w w .java2s . c om*/ final Map<String, Object> m = new TreeMap<String, Object>(); m.put("urlString", token.encodeToUrlString()); return m; }
From source file:com.cloudera.impala.security.DelegationTokenSecretManager.java
License:Apache License
public synchronized DelegationTokenManager.DelegationToken getDelegationToken(String owner, String renewer, String realUser) throws IOException { if (realUser == null) realUser = owner;//from ww w . ja v a2 s . c o m DelegationTokenIdentifier ident = new DelegationTokenIdentifier(new Text(owner), new Text(renewer), new Text(realUser)); Token<DelegationTokenIdentifier> t = new Token<DelegationTokenIdentifier>(ident, this); return new DelegationTokenManager.DelegationToken(encodeIdentifier(ident.serialize()), encodePassword(t.getPassword()), t.encodeToUrlString().getBytes()); }
From source file:com.cloudera.impala.security.DelegationTokenSecretManager.java
License:Apache License
public synchronized String getDelegationToken(String renewer) throws IOException { UserGroupInformation ugi = UserGroupInformation.getCurrentUser(); Text owner = new Text(ugi.getUserName()); Text realUser = null;/*from ww w .ja va 2 s .c o m*/ if (ugi.getRealUser() != null) { realUser = new Text(ugi.getRealUser().getUserName()); } DelegationTokenIdentifier ident = new DelegationTokenIdentifier(owner, new Text(renewer), realUser); Token<DelegationTokenIdentifier> t = new Token<DelegationTokenIdentifier>(ident, this); LOGGER.info("Generated delegation token. Identifer=" + ident); return t.encodeToUrlString(); }
From source file:com.cloudera.recordservice.mr.security.TokenUtils.java
License:Apache License
/** * Serializes a token to TDelegationToken. *//* www . ja v a 2 s.c om*/ public static DelegationToken toDelegationToken(Token<DelegationTokenIdentifier> t) throws IOException { if (t == null) return null; return new DelegationToken(encodeAsString(t.getIdentifier()), encodeAsString(t.getPassword()), t.encodeToUrlString().getBytes()); }
From source file:com.datatorrent.stram.security.StramWSFilter.java
License:Apache License
private String createClientToken(String username, String service) throws IOException { StramDelegationTokenIdentifier tokenIdentifier = new StramDelegationTokenIdentifier(new Text(username), new Text(loginUser), new Text()); //tokenIdentifier.setSequenceNumber(sequenceNumber.getAndAdd(1)); //byte[] password = tokenManager.addIdentifier(tokenIdentifier); //Token<StramDelegationTokenIdentifier> token = new Token<StramDelegationTokenIdentifier>(tokenIdentifier.getBytes(), password, tokenIdentifier.getKind(), new Text(service)); Token<StramDelegationTokenIdentifier> token = new Token<StramDelegationTokenIdentifier>(tokenIdentifier, tokenManager);//from w w w . j ava2 s . c om token.setService(new Text(service)); return token.encodeToUrlString(); }