{{theTime}}

Search This Blog

Total Pageviews

Privileged Actions Programming Idioms

Sample PackageAccess method implementation.

private void checkPackageAccess(Class class, ProtectionDomain domain) {
        final SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            final String classname= class.getName();
            final int i = classname.lastIndexOf('.');
            if (i != -1) {
                AccessController.doPrivileged(new PrivilegedAction<Void>() {
                    public Void run() {
                        sm.checkPackageAccess(classname.substring(0, i));
                        return null;
                    }
                }, new AccessControlContext(new ProtectionDomain[] {domain}));
            }
        }
        domains.add(domain);
    }

No comments:

Generate Insert Sql from Select Statement

SELECT 'INSERT INTO ReferenceTable (ID, Name) VALUES (' +        CAST(ID AS NVARCHAR) + ', ''' + Name + ''...