Package java.security

Examples of java.security.Policy$UnsupportedEmptyCollection


        //commit
        for (String contextId : contextIdToPermissionsMap.keySet()) {
            contextIdToPolicyConfigurationMap.get(contextId).commit();
        }
        //refresh policy
        Policy policy = Policy.getPolicy();
        policy.refresh();
    }
View Full Code Here


            PolicyConfiguration policyConfiguration = (PolicyConfiguration) iterator.next();
            policyConfiguration.commit();
        }

        //refresh policy
        Policy policy = Policy.getPolicy();
        policy.refresh();

        for (Iterator iterator = roleDesignates.entrySet().iterator(); iterator.hasNext();) {
            Map.Entry entry = (Map.Entry) iterator.next();
            Subject roleDesignate = (Subject) entry.getValue();
            ContextManager.registerSubject(roleDesignate);
View Full Code Here

        if (!POLICY_INSTALLED) {
            policyProvider = sysOverRide(policyProvider, POLICY_PROVIDER);

            if (policyProvider != null) {
                Policy policy = (Policy) classLoader.loadClass(policyProvider).newInstance();
                policy.refresh();
                Policy.setPolicy(policy);
            }

            POLICY_INSTALLED = true;
        }
View Full Code Here

    CodeSource ejbCS = clazz.getProtectionDomain().getCodeSource();

    try {
      setContextID( contextID );

      Policy policy = Policy.getPolicy();
      // Get the caller
      Subject caller = getContextSubject();

      Principal[] principals = null;
      if ( caller != null ) {
        // Get the caller principals
        Set principalsSet = caller.getPrincipals();
        principals = new Principal[ principalsSet.size() ];
        principalsSet.toArray( principals );
      }

      ProtectionDomain pd = new ProtectionDomain( ejbCS, null, null, principals );
      if ( policy.implies( pd, methodPerm ) == false ) {
        String msg = "Denied: " + methodPerm + ", caller=" + caller;
        SecurityException e = new SecurityException( msg );
        throw e;
      }
    }
View Full Code Here

        try {
            // The policy file may have been modified to adjust
            // permissions, so we're reloading it when loading or
            // reloading a Context
            Policy policy = Policy.getPolicy();
            policy.refresh();
        } catch (AccessControlException e) {
            // Some policy files may restrict this, even for the core,
            // so this exception is ignored
        }
View Full Code Here

    /**
     * Installs a SecurityManager on behalf of the application
     */
    public void installSecurityManager(){
        Policy policy = Policy.getPolicy();
        BatikSecurityManager securityManager = new BatikSecurityManager();

        // Specify app's security policy in the
        // system property.
        ClassLoader cl = appMainClass.getClassLoader();
        URL url = cl.getResource(securityPolicy);

        if (url == null) {
            throw new NullPointerException
                (Messages.formatMessage(EXCEPTION_NO_POLICY_FILE,
                                        new Object[]{securityPolicy}));
        }

        System.setProperty(PROPERTY_JAVA_SECURITY_POLICY,
                           url.toString());

        //
        // The following detects whether the application is running in the
        // development environment, in which case it will set the
        // app.dev.base property or if it is running in the binary
        // distribution, in which case it will set the app.jar.base
        // property. These properties are expanded in the security
        // policy files.
        // Property expansion is used to provide portability of the
        // policy files between various code bases (e.g., file base,
        // server base, etc..).
        //
        url = cl.getResource(appMainClassRelativeURL);
        if (url == null){
            // Something is really wrong: we would be running a class
            // which can't be found....
            throw new Error(appMainClassRelativeURL);
        }
       
        String expandedMainClassName = url.toString();
        if (expandedMainClassName.startsWith(JAR_PROTOCOL) ) {
            setJarBase(expandedMainClassName);
        } else {
            setDevBase(expandedMainClassName);
        }
       
        // Install new security manager
        System.setSecurityManager(securityManager);
        lastSecurityManagerInstalled = securityManager;

        // Forces re-loading of the security policy
        policy.refresh();
    }
View Full Code Here

    /**
     * Installs a SecurityManager on behalf of the application
     */
    public void installSecurityManager(){
        Policy policy = Policy.getPolicy();
        BatikSecurityManager securityManager = new BatikSecurityManager();

        //
        // If there is a java.security.policy property defined,
        // it takes precedence over the one passed to this object.
        // Otherwise, we default to the one passed to the constructor
        //
        ClassLoader cl = appMainClass.getClassLoader();
        String securityPolicyProperty
            = System.getProperty(PROPERTY_JAVA_SECURITY_POLICY);

        if (securityPolicyProperty == null || securityPolicyProperty.equals("")) {
            // Specify app's security policy in the
            // system property.
            URL policyURL = getPolicyURL();
           
            System.setProperty(PROPERTY_JAVA_SECURITY_POLICY,
                               policyURL.toString());
        }
       
        //
        // The following detects whether the application is running in the
        // development environment, in which case it will set the
        // app.dev.base property or if it is running in the binary
        // distribution, in which case it will set the app.jar.base
        // property. These properties are expanded in the security
        // policy files.
        // Property expansion is used to provide portability of the
        // policy files between various code bases (e.g., file base,
        // server base, etc..).
        //
        URL mainClassURL = cl.getResource(appMainClassRelativeURL);
        if (mainClassURL == null){
            // Something is really wrong: we would be running a class
            // which can't be found....
            throw new Error(appMainClassRelativeURL);
        }
       
        String expandedMainClassName = mainClassURL.toString();
        if (expandedMainClassName.startsWith(JAR_PROTOCOL) ) {
            setJarBase(expandedMainClassName);
        } else {
            setDevBase(expandedMainClassName);
        }
       
        // Install new security manager
        System.setSecurityManager(securityManager);
        lastSecurityManagerInstalled = securityManager;
       
        // Forces re-loading of the security policy
        policy.refresh();

        if (securityPolicyProperty == null || securityPolicyProperty.equals("")) {
            System.setProperty(PROPERTY_JAVA_SECURITY_POLICY, "");
        }
    }
View Full Code Here

        try {
            // The policy file may have been modified to adjust
            // permissions, so we're reloading it when loading or
            // reloading a Context
            Policy policy = Policy.getPolicy();
            policy.refresh();
        } catch (AccessControlException e) {
            // Some policy files may restrict this, even for the core,
            // so this exception is ignored
        }
View Full Code Here

        String policyProvider = System.getProperty("javax.security.jacc.policy.provider", JaccProvider.Policy.class.getName());
        try {
            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            Class policyClass = Class.forName(policyProvider, true, classLoader);
            Policy policy = (Policy) policyClass.newInstance();
            policy.refresh();
            Policy.setPolicy(policy);
        } catch (Exception e) {
            throw new IllegalStateException("Could not install JACC Policy Provider: "+policyProvider, e);
        }
    }
View Full Code Here

        // 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();
                }
                if (!docBase.endsWith(File.separator)){
                    docBase = docBase + File.separator;
                }
                File contextDir = new File(docBase);
                URL url = contextDir.getCanonicalFile().toURL();
                codeSource = new CodeSource(url,null);
                permissionCollection = policy.getPermissions(codeSource);

                // Create a file read permission for web app context directory
                docBase = docBase + "-";
                permissionCollection.add(new FilePermission(docBase,"read"));
View Full Code Here

TOP

Related Classes of java.security.Policy$UnsupportedEmptyCollection

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.