db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicholas walton <nwalton250...@gmail.com>
Subject Security problem with ggregate functions using Java
Date Fri, 17 Feb 2017 17:42:37 GMT
Hi,

I need to extend Java’s aggregate functions to include Median, using the code below

import java.util.ArrayList;
import java.util.Collections;
import org.apache.derby.agg.Aggregator;

public class median<V extends Comparable<V>> 
      implements Aggregator<V,V,median<V>>
{
  private ArrayList<V> _values;

  public median() {}

  public void init() { _values = new ArrayList<V>(); }

  public void accumulate( V value ) { _values.add( value ); }

  public void merge( median<V> other )
  { 
      _values.addAll( other._values ); 
  }

  public V terminate()
  {
      Collections.sort( _values );

      int count = _values.size();

      if ( count == 0 ) { return null; }
      else { return _values.get( count/2 ); }
  }
}

To install I used

CALL SQLJ.INSTALL_JAR('/Users/nwalton/Documents/Databases/derbyStats/dist/derbyStats.jar',
'NWALTON.median',0);
CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY ('derby.database.classpath','NWALTON.median’);

CREATE DERBY AGGREGATE "NWALTON"."MEDIAN" FOR DOUBLE RETURNS DOUBLE EXTERNAL NAME 'aggregates.median’
;

At first this works fine in a trigger or in plain SQL but after a while I get the following
error

Error code 30000, SQL state 38000: The exception 'java.security.AccessControlException: access
denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.reflect")' was thrown while
evaluating an expression.
Error code 99999, SQL state XJ001: Java exception: 'access denied ("java.lang.RuntimePermission"
"accessClassInPackage.sun.reflect"): java.security.AccessControlException'.
Line 1, column 1

I’ve Googled to no avail for an answer! Can anyone suggest a solution. I’m running OS
X Sierra Apache Derby Network Server - 10.6.2.1 - (999685) under Java version 1.8.0_31-b13.

Thanks in advance

Nick 
Mime
View raw message