@Test public void testCreate_differentTicketsDifferentClient() { PermissionTicket perm1 = permissionService.createTicket(rs1, scopes1); PermissionTicket perm2 = permissionService.createTicket(rs2, scopes2); assertNotNull(perm1.getTicket()); assertNotNull(perm2.getTicket()); assertThat(perm1.getTicket(), not(equalTo(perm2.getTicket()))); }
@Override public PermissionTicket createTicket(ResourceSet resourceSet, Set<String> scopes) { if (!scopeService.scopesMatch(resourceSet.getScopes(), scopes)) { throw new InsufficientScopeException("Scopes of resource set are not enough for requested permission."); } Permission perm = new Permission(); perm.setResourceSet(resourceSet); perm.setScopes(scopes); PermissionTicket ticket = new PermissionTicket(); ticket.setPermission(perm); ticket.setTicket(UUID.randomUUID().toString()); ticket.setExpiration(new Date(System.currentTimeMillis() + permissionExpirationSeconds * 1000L)); return repository.save(ticket); }
DefaultPermissionService implements PermissionService { @Override public PermissionTicket createTicket(ResourceSet resourceSet, Set<String> scopes) { if (!scopeService.scopesMatch(resourceSet.getScopes(), scopes)) { throw new InsufficientScopeException("Scopes of resource set are not enough for requested permission."); } Permission perm = new Permission(); perm.setResourceSet(resourceSet); perm.setScopes(scopes); PermissionTicket ticket = new PermissionTicket(); ticket.setPermission(perm); ticket.setTicket(UUID.randomUUID().toString()); ticket.setExpiration(new Date(System.currentTimeMillis() + permissionExpirationSeconds * 1000L)); return repository.save(ticket); } }
DefaultPermissionService implements PermissionService { @Override public PermissionTicket createTicket(ResourceSet resourceSet, Set<String> scopes) { if (!scopeService.scopesMatch(resourceSet.getScopes(), scopes)) { throw new InsufficientScopeException("Scopes of resource set are not enough for requested permission."); } Permission perm = new Permission(); perm.setResourceSet(resourceSet); perm.setScopes(scopes); PermissionTicket ticket = new PermissionTicket(); ticket.setPermission(perm); ticket.setTicket(UUID.randomUUID().toString()); ticket.setExpiration(new Date(System.currentTimeMillis() + permissionExpirationSeconds * 1000L)); return repository.save(ticket); }  }
DefaultPermissionService implements PermissionService { @Override public PermissionTicket createTicket(ResourceSet resourceSet, Set<String> scopes) { if (!scopeService.scopesMatch(resourceSet.getScopes(), scopes)) { throw new InsufficientScopeException("Scopes of resource set are not enough for requested permission."); } Permission perm = new Permission(); perm.setResourceSet(resourceSet); perm.setScopes(scopes); PermissionTicket ticket = new PermissionTicket(); ticket.setPermission(perm); ticket.setTicket(UUID.randomUUID().toString()); ticket.setExpiration(new Date(System.currentTimeMillis() + permissionExpirationSeconds * 1000L)); return repository.save(ticket); }  @Override PermissionTicket createTicket(ResourceSet resourceSet, Set<String> scopes); @Override PermissionTicket getByTicket(String ticket); @Override PermissionTicket updateTicket(PermissionTicket ticket); }
DefaultPermissionService implements PermissionService { @Override public PermissionTicket createTicket(ResourceSet resourceSet, Set<String> scopes) { if (!scopeService.scopesMatch(resourceSet.getScopes(), scopes)) { throw new InsufficientScopeException("Scopes of resource set are not enough for requested permission."); } Permission perm = new Permission(); perm.setResourceSet(resourceSet); perm.setScopes(scopes); PermissionTicket ticket = new PermissionTicket(); ticket.setPermission(perm); ticket.setTicket(UUID.randomUUID().toString()); ticket.setExpiration(new Date(System.currentTimeMillis() + permissionExpirationSeconds * 1000L)); return repository.save(ticket); }  @Override PermissionTicket createTicket(ResourceSet resourceSet, Set<String> scopes); @Override PermissionTicket getByTicket(String ticket); @Override PermissionTicket updateTicket(PermissionTicket ticket);  }