Re: Security problem with ggregate functions using Java

2017-02-17 Thread toma.george89
Hi Nicholas,


I think that your issue is due to java policy ( either you need to change your 
Java policy file, or if you supply any do your derby context, update this one ).


Please check https://docs.oracle.com/cd/E19225-01/820-5594/ahtbo/index.html, 
and 

this 
http://docs.oracle.com/javase/7/docs/technotes/guides/security/permissions.html 

for more information.


In the end , I believe that you will need to append accessClassInPackage rights 
to the derby aggregator, org.apache.derby.agg.Aggregator;.



E.g. :

grant{ 
permission java.lang.RuntimePermission 
"accessClassInPackage.org.apache.derby.agg";
}



Regards,

George











Sent from Windows Mail





From: nicholas walton
Sent: ‎Friday‎, ‎February‎ ‎17‎, ‎2017 ‎7‎:‎42‎ ‎PM
To: derby-user@db.apache.org




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> 
  implements Aggregator
{
  private ArrayList _values;

  public median() {}

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

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

  public void merge( median 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 3, SQL state 38000: The exception 
'java.security.AccessControlException: access denied 
("java.lang.RuntimePermission" "accessClassInPackage.sun.reflect")' was thrown 
while evaluating an expression.
Error code 9, 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

Re: Use Apache Derby Network Server with encrypted database

2016-08-24 Thread toma.george89
Hi Gerrit,




Based on Apache Derby page, between the embedded mode and network mode there is 
no difference, 
https://db.apache.org/derby/docs/10.0/manuals/admin/hubprnt19.html#Differences+between+running+Derby+in+embedded+mode+and+using+the+Network+Server




Have you tried to create an encrypted database via the network mode using the 
steps mentioned in your link ? It should work, otherwise can you please post 
your errors/stacktrace/exceptions.


What I did on my side to try your scenario :

Start Apache Derby in network mode


Create a dummy encrypted database and connect to it via ij:


 connect 'jdbc:derby://localhost:1527/MyDbTest;create=true;dataEncryption=true';


After that I’ve started to create tables and to execute SQL queries (select), 
just to play with the database.


It worked, no difference between embedded vs network mode.


Remember to append to the URL the host and the port where Apache Derby server 
is started ( in my case it was localhost : 1527).



What I’ve followed in order to achieve the above:

http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#ij_ns_client


http://db.apache.org/derby/papers/DerbyTut/ij_intro.html#ij_connect


https://db.apache.org/derby/docs/10.0/manuals/develop/develop15.html


If you want a more custom example regarding the algorithm that can be used to 
encrypt the database, please have a look into this page :


https://db.apache.org/derby/docs/10.2/ref/rrefattribencryptkey.html



If you need more information, please let me know.




Regards,

George








Sent from Windows Mail





From: Hohl, Gerrit
Sent: ‎Wednesday‎, ‎August‎ ‎24‎, ‎2016 ‎10‎:‎15‎ ‎AM
To: derby-user@db.apache.org






Hello everyone,

 

I've used Apache Derby for years now as an embedded RDBMS.

BTW: Thanks to all developer doing a great job developing this database system. 
:-D

 

But now I want to use it as a separate service running on Ubuntu Linux.

This is no problem.

 

But I haven't found any explanation or example how to create and use encrypted 
database if I'm running Derby as a service.

 

I found only this page:

https://db.apache.org/derby/docs/10.0/manuals/develop/develop115.html

But it seems it only deals with an embedded Derby version.

 

Regards,

Gerrit