@Override public EzSecurityToken refreshSecurityToken(EzSecurityToken token) throws EzSecurityTokenException { EzSecurityToken refreshedToken; EzSecurity.Client client = null; try { TokenRequest request = new TokenRequest(securityId, System.currentTimeMillis(), token.getType()); request.setTokenPrincipal(token); client = pool.get().getClient(ezsecurityConstants.SERVICE_NAME, EzSecurity.Client.class); refreshedToken = client.refreshToken(request, ""); } catch (AppNotRegisteredException e) { log.error("Application {} is not registered with EzSecurity", securityId, e); throw new EzSecurityTokenException("Application not registered " + e.getMessage()); } catch (TException e) { log.error("Unexpected thrift exception getting security token: {}", e.getMessage()); throw new EzSecurityTokenException("TException getting security token: " + e.getMessage()); } finally { if (client != null) { pool.get().returnToPool(client); } } return refreshedToken; }
@Override public EzSecurityToken getSecurityToken(TokenRequest tokenRequest) throws EzSecurityTokenException { EzSecurityToken token; EzSecurity.Client client = null; try { client = pool.get().getClient(ezsecurityConstants.SERVICE_NAME, EzSecurity.Client.class); token = client.requestToken(tokenRequest, ""); } catch (AppNotRegisteredException e) { log.error("Application {} is not registered with EzSecurity", securityId, e); throw new EzSecurityTokenException("Application not registered " + e.getMessage()); } catch (TException e) { log.error("Unexpected thrift exception getting security token: {}", e.getMessage()); throw new EzSecurityTokenException("TException getting security token: " + e.getMessage()); } finally { pool.get().returnToPool(client); } return token; }