Package org.codehaus.loom.xmlpolicy.metadata

Examples of org.codehaus.loom.xmlpolicy.metadata.PolicyMetaData


    }

    private void verifyResource( final String resource )
        throws Exception
    {
        final PolicyMetaData defs = buildFromResource( resource );
        final PolicyVerifier verifier = new PolicyVerifier();
        verifier.verifyPolicy( defs );
    }
View Full Code Here


        m_expander.expandValues( element, newData );

        element.setAttribute( "version", "1.0" );
        try
        {
            final PolicyMetaData policy = reader.readPolicy( element );
            verifier.verifyPolicy( policy );
            return builder.buildPolicy( policy, resolver );
        }
        catch( final Exception e )
        {
View Full Code Here

    }

    public void testConfig1()
        throws Exception
    {
        final PolicyMetaData policy = buildFromResource( "config1.xml" );

        assertEquals( "Policy KeyStore Count",
                      1,
                      policy.getKeyStores().length );

        final KeyStoreMetaData keyStore = policy.getKeyStores()[ 0 ];
        assertEquals( "KeyStore Name",
                      "myKeystore",
                      keyStore.getName() );
        assertEquals( "KeyStore Location",
                      "sar:/conf/keystore",
                      keyStore.getLocation() );
        assertEquals( "KeyStore Type",
                      "JKS",
                      keyStore.getType() );

        assertEquals( "Policy Grant Count",
                      2,
                      policy.getGrants().length );

        final GrantMetaData grant1 = policy.getGrants()[ 0 ];
        final GrantMetaData grant2 = policy.getGrants()[ 1 ];

        assertEquals( "grant1.getCodebase()",
                      "myCodeBase",
                      grant1.getCodebase() );
        assertEquals( "grant1.getKeyStore()",
View Full Code Here

    }

    public void testConfig4()
        throws Exception
    {
        final PolicyMetaData policy = buildFromResource( "config4.xml" );
        assertEquals( "Policy KeyStore Count",
                      0,
                      policy.getKeyStores().length );

        assertEquals( "Policy Grant Count",
                      1,
                      policy.getGrants().length );

        final GrantMetaData grant1 = policy.getGrants()[ 0 ];

        assertEquals( "grant1.getCodebase()",
                      null,
                      grant1.getCodebase() );
        assertEquals( "grant1.getKeyStore()",
View Full Code Here

    }

    public void testConfig5()
        throws Exception
    {
        final PolicyMetaData policy = buildFromResource( "config5.xml" );

        assertEquals( "Policy KeyStore Count",
                      1,
                      policy.getKeyStores().length );

        final KeyStoreMetaData keyStore = policy.getKeyStores()[ 0 ];
        assertEquals( "KeyStore Name",
                      "default",
                      keyStore.getName() );
        assertEquals( "KeyStore Location",
                      "sar:/conf/keystore",
                      keyStore.getLocation() );
        assertEquals( "KeyStore Type",
                      "JKS",
                      keyStore.getType() );

        assertEquals( "Policy Grant Count",
                      2,
                      policy.getGrants().length );

        final GrantMetaData grant1 = policy.getGrants()[ 0 ];
        final GrantMetaData grant2 = policy.getGrants()[ 1 ];

        assertEquals( "grant1.getCodebase()",
                      "myCodeBase",
                      grant1.getCodebase() );
        assertEquals( "grant1.getKeyStore()",
View Full Code Here

    public void testEmptyMetaData()
        throws Exception
    {
        final PolicyBuilder builder = new PolicyBuilder();
        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 =
View Full Code Here

    public void testNullResolverInBuildPolicy()
        throws Exception
    {
        final PolicyBuilder builder = new PolicyBuilder();
        final PolicyMetaData metaData =
            new PolicyMetaData( new KeyStoreMetaData[ 0 ], new GrantMetaData[ 0 ] );
        try
        {
            builder.buildPolicy( metaData, null );
            fail( "Expected to fail due to null pointer in buildPolicy" );
        }
View Full Code Here

        final PermissionMetaData permission =
            new PermissionMetaData( AllPermission.class.getName(), null, null, null, null );
        final GrantMetaData grant =
            new GrantMetaData( "file:/", null, null,
                               new PermissionMetaData[]{permission} );
        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 =
View Full Code Here

        final GrantMetaData grant =
            new GrantMetaData( "file:/", "jenny", "default",
                               new PermissionMetaData[]{permission} );
        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 );
View Full Code Here

        final GrantMetaData grant =
            new GrantMetaData( "file:/", "jenny,mischelle,jenny", "default",
                               new PermissionMetaData[]{permission} );
        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 );
View Full Code Here

TOP

Related Classes of org.codehaus.loom.xmlpolicy.metadata.PolicyMetaData

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.