// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

// ================================================================
// Example JSE Java 2 security policy required by OpenJPA.
//
//   -Djava.security.manager -Djava.security.policy=C:\j2.security.jse.policy

// ----------------------------------------------------------------
// Application:  E.g.
//   -Dapplication=file:///C:/com/my/appl/classes

grant CodeBase "${application}/-" {

    // Allows Persistence.createEntityManagerFacotry() to read META-INF/*
    permission java.io.FilePermission   "<<ALL FILES>>", "read";
};

// ----------------------------------------------------------------
// Derby:  E.g.
//   -Dderby.base="file:///C:\.m2\repository\org\apache\derby\derby\10.2.2.0

grant CodeBase "${derby.base}/-" {

    permission java.io.FilePermission   "<<ALL FILES>>", "read,write,delete";
    permission java.lang.RuntimePermission               "createClassLoader";
    permission java.util.PropertyPermission         "*", "read";
};

// ----------------------------------------------------------------
// DB2:  E.g.
//  -db2.base=file:///C:/sqllib/java

grant CodeBase "${db2.base}/-" {

    permission java.lang.RuntimePermission               "loadLibrary.*";
    permission java.util.PropertyPermission         "*", "read";
};


// ================================================================
// The following permissions are required by OpenJPA implementation.

// ----------------------------------------------------------------
// Serp:  E.g.
//  -Dserp.base="file:///C:\.m2\repository\net\sourceforge\serp\serp\1.11.0"

grant CodeBase "${serp.base}/-" {

    permission java.io.FilePermission   "<<ALL FILES>>", "read,write";
    permission java.lang.RuntimePermission               "createClassLoader";
};

// ----------------------------------------------------------------
// OpeJPA:  E.g.
//  -Dopenjpa.base=file:///C:\openjpa.cur\openjpa-all\target

grant CodeBase "${openjpa.base}/-" {

    permission java.io.FilePermission   "<<ALL FILES>>", "read,write";
    permission java.lang.RuntimePermission               "createClassLoader";
    permission java.lang.reflect.ReflectPermission       "suppressAccessChecks";
    permission java.util.PropertyPermission         "*", "read";
};

