@Override public boolean isAuthorized( @WebParam(name = "authenticationData", targetNamespace = "") List<SecretAuthenticationKey> authenticationData, @WebParam(name = "action", targetNamespace = "") Action action) throws SNAAExceptionException { if (authenticationData == null || action == null) { throw createSNAAException("Arguments must not be null!"); } Map<String, Set<SecretAuthenticationKey>> intersectionPrefixSet = getIntersectionPrefixSetSAK(authenticationData); Set<Future<Boolean>> futures = new HashSet<Future<Boolean>>(); for (String urnPrefix : intersectionPrefixSet.keySet()) { IsAuthorizedCallable authenticationCallable = new IsAuthorizedCallable( getWsnUrlFromUrnPrefix(urnPrefix), new ArrayList<SecretAuthenticationKey>(intersectionPrefixSet.get(urnPrefix)), action); Future<Boolean> future = executorService.submit(authenticationCallable); futures.add(future); } for (Future<Boolean> future : futures) { try { if (!future.get()) { return false; } } catch (InterruptedException e) { throw createSNAAException(e.getMessage()); } catch (ExecutionException e) { throw createSNAAException(e.getMessage()); } } return true; }
@Override public List<SecretAuthenticationKey> authenticate( @WebParam(name = "authenticationData", targetNamespace = "") List<AuthenticationTriple> authenticationData) throws AuthenticationExceptionException, SNAAExceptionException { Map<String, Set<AuthenticationTriple>> intersectionPrefixSet = getIntersectionPrefixSetAT(authenticationData); Set<Future<List<SecretAuthenticationKey>>> futures = new HashSet<Future<List<SecretAuthenticationKey>>>(); for (String wsEndpointUrl : intersectionPrefixSet.keySet()) { AuthenticationCallable authenticationCallable = new AuthenticationCallable( wsEndpointUrl, new ArrayList<AuthenticationTriple>(intersectionPrefixSet.get(wsEndpointUrl))); Future<List<SecretAuthenticationKey>> future = executorService.submit(authenticationCallable); futures.add(future); } List<SecretAuthenticationKey> resultSet = new LinkedList<SecretAuthenticationKey>(); for (Future<List<SecretAuthenticationKey>> future : futures) { try { resultSet.addAll(future.get()); } catch (InterruptedException e) { SNAAException exception = new SNAAException(); exception.setMessage(e.getMessage()); throw new SNAAExceptionException(e.getMessage(), exception, e); } catch (ExecutionException e) { SNAAException exception = new SNAAException(); exception.setMessage(e.getMessage()); throw new SNAAExceptionException(e.getMessage(), exception, e); } } return resultSet; }