}
@Override
public WrapAccessTokenResult wrapAccessToken(String uri, String name,
String password, String scope) throws ServiceException {
Form requestForm = new Form();
requestForm.add("wrap_name", name);
requestForm.add("wrap_password", password);
requestForm.add("wrap_scope", scope);
Form responseForm;
try {
responseForm = channel.resource(uri)
.accept(MediaType.APPLICATION_FORM_URLENCODED)
.type(MediaType.APPLICATION_FORM_URLENCODED)
.post(Form.class, requestForm);
} catch (UniformInterfaceException e) {
log.warn("WRAP server returned error acquiring access_token", e);
throw ServiceExceptionFactory.process("WRAP", new ServiceException(
"WRAP server returned error acquiring access_token", e));
}
WrapAccessTokenResult response = new WrapAccessTokenResult();
response.setAccessToken(responseForm.getFirst("wrap_access_token"));
String expiresIn = responseForm
.getFirst("wrap_access_token_expires_in");
response.setExpiresIn(Long.parseLong(expiresIn));
return response;
}