@POST @Path("/delegation-token/expiration") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response postDelegationTokenExpiration(@Context HttpServletRequest hsr) throws AuthorizationException, IOException, InterruptedException, Exception { init(); UserGroupInformation callerUGI; try { callerUGI = createKerberosUserGroupInformation(hsr); } catch (YarnException ye) { return Response.status(Status.FORBIDDEN).entity(ye.getMessage()).build(); } DelegationToken requestToken = new DelegationToken(); requestToken.setToken(extractToken(hsr).encodeToUrlString()); return renewDelegationToken(requestToken, hsr, callerUGI); }
@POST @Path("/delegation-token/expiration") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response postDelegationTokenExpiration(@Context HttpServletRequest hsr) throws AuthorizationException, IOException, InterruptedException, Exception { init(); UserGroupInformation callerUGI; try { callerUGI = createKerberosUserGroupInformation(hsr); } catch (YarnException ye) { return Response.status(Status.FORBIDDEN).entity(ye.getMessage()).build(); } DelegationToken requestToken = new DelegationToken(); requestToken.setToken(extractToken(hsr).encodeToUrlString()); return renewDelegationToken(requestToken, hsr, callerUGI); }
@POST @Path(RMWSConsts.DELEGATION_TOKEN_EXPIRATION) @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response postDelegationTokenExpiration(@Context HttpServletRequest hsr) throws AuthorizationException, IOException, InterruptedException, Exception { UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); initForWritableEndpoints(callerUGI, false); try { createKerberosUserGroupInformation(hsr, callerUGI); callerUGI.setAuthenticationMethod(AuthenticationMethod.KERBEROS); } catch (YarnException ye) { return Response.status(Status.FORBIDDEN).entity(ye.getMessage()).build(); } DelegationToken requestToken = new DelegationToken(); requestToken.setToken(extractToken(hsr).encodeToUrlString()); return renewDelegationToken(requestToken, hsr, callerUGI); }
public static DelegationToken getDelegationTokenFromXML(String tokenXML) throws IOException, ParserConfigurationException, SAXException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(tokenXML)); Document dom = db.parse(is); NodeList nodes = dom.getElementsByTagName("delegation-token"); assertEquals("incorrect number of elements", 1, nodes.getLength()); Element element = (Element) nodes.item(0); DelegationToken ret = new DelegationToken(); String token = WebServicesTestUtils.getXmlString(element, "token"); if (token != null) { ret.setToken(token); } else { long expiration = WebServicesTestUtils.getXmlLong(element, "expiration-time"); ret.setNextExpirationTime(expiration); } return ret; }
public static DelegationToken getDelegationTokenFromXML(String tokenXML) throws IOException, ParserConfigurationException, SAXException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(tokenXML)); Document dom = db.parse(is); NodeList nodes = dom.getElementsByTagName("delegation-token"); assertEquals("incorrect number of elements", 1, nodes.getLength()); Element element = (Element) nodes.item(0); DelegationToken ret = new DelegationToken(); String token = WebServicesTestUtils.getXmlString(element, "token"); if (token != null) { ret.setToken(token); } else { long expiration = WebServicesTestUtils.getXmlLong(element, "expiration-time"); ret.setNextExpirationTime(expiration); } return ret; }
public static DelegationToken getDelegationTokenFromJson(JSONObject json) throws JSONException { DelegationToken ret = new DelegationToken(); if (json.has("token")) { ret.setToken(json.getString("token")); } else if (json.has("expiration-time")) { ret.setNextExpirationTime(json.getLong("expiration-time")); } return ret; }
public static DelegationToken getDelegationTokenFromJson(JSONObject json) throws JSONException { DelegationToken ret = new DelegationToken(); if (json.has("token")) { ret.setToken(json.getString("token")); } else if (json.has("expiration-time")) { ret.setNextExpirationTime(json.getLong("expiration-time")); } return ret; }