Package java.security

Examples of java.security.Policy$Parameters


        // Setup the PermissionCollection for this web app context
        // based on the permissions configured for the root of the
        // web app context directory, then add a file read permission
        // for that directory.
        Policy policy = Policy.getPolicy();
        if( policy != null ) {
            try {         
                // Get the permissions for the web app context
                String docBase = context.getRealPath("/");
                if( docBase == null ) {
                    docBase = options.getScratchDir().toString();
                }
                String codeBase = docBase;
                if (!codeBase.endsWith(File.separator)){
                    codeBase = codeBase + File.separator;
                }
                File contextDir = new File(codeBase);
                URL url = contextDir.getCanonicalFile().toURL();
                codeSource = new CodeSource(url,(Certificate[])null);
                permissionCollection = policy.getPermissions(codeSource);

                // Create a file read permission for web app context directory
                if (!docBase.endsWith(File.separator)){
                    permissionCollection.add
                        (new FilePermission(docBase,"read"));
View Full Code Here


        final File homeDirectory,
        final File workDirectory ) throws Exception
    {
        //Configure policy
        final Configuration policyConfig = environment.getChild( "policy" );
        final Policy policy = configurePolicy( policyConfig,
                                               data,
                                               homeDirectory,
                                               workDirectory );

        final ClassLoaderSetMetaData metaData = getLoaderMetaData( environment );
View Full Code Here

        final CodeSource codeSource = new CodeSource( url, new Certificate[ 0 ] );
        final AllPermission allPermission = new AllPermission();
        final HashMap grants = new HashMap();
        grants.put( codeSource, new Permission[]{allPermission} );

        final Policy policy = new DefaultPolicy( grants );
        policy.refresh();
        final PermissionCollection resultPermissions = policy.getPermissions( codeSource );
        final Enumeration enumeration = resultPermissions.elements();
        while( enumeration.hasMoreElements() )
        {
            final Permission permission = (Permission)enumeration.nextElement();
            assertEquals( "Permissions for codeSource" + codeSource,
View Full Code Here

        final CodeSource codeSource = new CodeSource( url, new Certificate[ 0 ] );
        final AllPermission allPermission = new AllPermission();
        final HashMap grants = new HashMap();
        grants.put( codeSource, new Permission[]{allPermission} );

        final Policy policy = new DefaultPolicy( grants );
        policy.refresh();
        final PermissionCollection resultPermissions = policy.getPermissions( new CodeSource( null, new Certificate[ 0 ] ) );
        final Enumeration enumeration = resultPermissions.elements();
        assertEquals( "Permissions for codeSource" + codeSource,
                      false, enumeration.hasMoreElements() );
    }
View Full Code Here

    }

    public void testPolicyAccessPermissionForNonSpecifiedCodeBase()
        throws Exception
    {
        final Policy policy = new DefaultPolicy();
        policy.refresh();

        final URL url = new URL( "http://spice.sourceforge.net/-" );
        final CodeSource codeSource = new CodeSource( url, new Certificate[ 0 ] );
        final PermissionCollection permissions = policy.getPermissions( codeSource );
        assertEquals( "Expect no permissions for http://...", false, permissions.elements().hasMoreElements() );

        final CodeSource otherCodeSource = new CodeSource( null, new Certificate[ 0 ] );
        final PermissionCollection otherPermissions = policy.getPermissions( otherCodeSource );
        assertEquals( "Expect no permissions for null location", false, otherPermissions.elements().hasMoreElements() );
    }
View Full Code Here

        final PolicyMetaData metaData =
            new PolicyMetaData( new KeyStoreMetaData[ 0 ], new GrantMetaData[ 0 ] );
        final TestResolver resolver = new TestResolver();
        try
        {
            final Policy policy = builder.buildPolicy( metaData, resolver );
            final PermissionCollection permissions =
                policy.getPermissions( new CodeSource( null, new Certificate[ 0 ] ) );
            assertEquals( "Expect no permissions for empty metaData",
                          false,
                          permissions.elements().hasMoreElements() );
        }
        catch( final Exception e )
View Full Code Here

        final PolicyMetaData metaData =
            new PolicyMetaData( new KeyStoreMetaData[ 0 ], new GrantMetaData[]{grant} );
        final TestResolver resolver = new TestResolver();
        try
        {
            final Policy policy = builder.buildPolicy( metaData, resolver );
            final CodeSource codesource =
                new CodeSource( new URL( "file:/" ), new Certificate[ 0 ] );
            final PermissionCollection permissions = policy.getPermissions( codesource );
            final Enumeration enumeration = permissions.elements();
            while( enumeration.hasMoreElements() )
            {
                final Object perm = enumeration.nextElement();
                if( perm instanceof AllPermission )
View Full Code Here

        final KeyStoreMetaData keyStore =
            new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
        final PolicyMetaData metaData =
            new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
        final TestResolver resolver = new TestResolver();
        final Policy policy = builder.buildPolicy( metaData, resolver );
        final CodeSource codesource =
            new CodeSource( new URL( "file:/" ), new Certificate[]{MockCertificate.JENNY_CERTIFICATE} );
        final PermissionCollection permissions = policy.getPermissions( codesource );
        final Enumeration enumeration = permissions.elements();
        while( enumeration.hasMoreElements() )
        {
            final Object perm = enumeration.nextElement();
            if( perm instanceof FilePermission )
View Full Code Here

        final KeyStoreMetaData keyStore =
            new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
        final PolicyMetaData metaData =
            new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
        final TestResolver resolver = new TestResolver();
        final Policy policy = builder.buildPolicy( metaData, resolver );
        final CodeSource codesource =
            new CodeSource( new URL( "file:/" ), new Certificate[]{MockCertificate.JENNY_CERTIFICATE} );
        final PermissionCollection permissions = policy.getPermissions( codesource );
        final Enumeration enumeration = permissions.elements();
        while( enumeration.hasMoreElements() )
        {
            final Object perm = enumeration.nextElement();
            if( perm instanceof RuntimePermission )
View Full Code Here

        final KeyStoreMetaData keyStore =
            new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
        final PolicyMetaData metaData =
            new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
        final TestResolver resolver = new TestResolver();
        final Policy policy = builder.buildPolicy( metaData, resolver );
        final CodeSource codesource =
            new CodeSource( new URL( "file:/" ), new Certificate[]{MockCertificate.JENNY_CERTIFICATE} );
        final PermissionCollection permissions = policy.getPermissions( codesource );
        final Enumeration enumeration = permissions.elements();
        while( enumeration.hasMoreElements() )
        {
            final Object perm = enumeration.nextElement();
            if( perm instanceof UnresolvedPermission )
View Full Code Here

TOP

Related Classes of java.security.Policy$Parameters

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.