Search in sources :

Example 6 with IASSecurityException

use of com.sun.enterprise.security.util.IASSecurityException in project Payara by payara.

the class SecurityUtil method linkPolicyFile.

/**
 * This method obtains the policy configuration object corresponding to the name, and links it, for roleMapping purposes
 * to another. If the pc is already InService when this method is called, this method does nothing.
 *
 * @param String name - the module id which serves to identify the corresponding policy context. The name shall not be
 * null.
 * @param String linkName - the module id of the module being linked to this context. This value may be null, in which
 * case, no link is done, but the inService state of the named PC is returned.
 * @param boolean lastInService - the inService state returned by the previous call to this method. The value of this
 * argument is only significant when linkName is not null.
 * @return boolean if linkName is null, returns the inService state of the PC identified in the name argument. Otherwise
 * returns the value passed to lastInService.
 */
public static boolean linkPolicyFile(String name, String linkName, boolean lastInService) throws IASSecurityException {
    boolean rvalue = lastInService;
    assert name != null;
    if (name == null) {
        throw new IASSecurityException("Invalid Module Name");
    }
    try {
        PolicyConfigurationFactory pcf = PolicyConfigurationFactory.getPolicyConfigurationFactory();
        boolean inService = pcf.inService(name);
        if (linkName == null) {
            rvalue = inService;
        } else if (inService == lastInService) {
            // only do the link if the named PC is not inService.
            if (!inService) {
                // find the PolicyConfigs using remove=false to ensure policy stmts
                // are retained.
                PolicyConfiguration pc = pcf.getPolicyConfiguration(name, false);
                PolicyConfiguration linkPc = pcf.getPolicyConfiguration(linkName, false);
                pc.linkConfiguration(linkPc);
            }
        } else {
            throw new IASSecurityException("Inconsistent Module State");
        }
    } catch (java.lang.ClassNotFoundException cnfe) {
        String msg = localStrings.getLocalString("enterprise.security.securityutil.classnotfound", "Could not find PolicyConfigurationFactory class. Check javax.security.jacc.PolicyConfigurationFactory.provider property");
        throw new IASSecurityException(msg);
    } catch (javax.security.jacc.PolicyContextException pce) {
        throw new IASSecurityException(pce.toString());
    }
    return rvalue;
}
Also used : javax.security.jacc(javax.security.jacc) IASSecurityException(com.sun.enterprise.security.util.IASSecurityException)

Aggregations

IASSecurityException (com.sun.enterprise.security.util.IASSecurityException)6 javax.security.jacc (javax.security.jacc)3 DeploymentException (org.glassfish.deployment.common.DeploymentException)3 OpsParams (org.glassfish.api.deployment.OpsParams)2 EJBTimerService (com.sun.ejb.containers.EJBTimerService)1 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)1 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Properties (java.util.Properties)1 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)1 UndeployCommandParameters (org.glassfish.api.deployment.UndeployCommandParameters)1 DeploymentProperties (org.glassfish.deployment.common.DeploymentProperties)1 EJBSecurityManager (org.glassfish.ejb.security.application.EJBSecurityManager)1 EngineRef (org.glassfish.internal.data.EngineRef)1 ProgressTracker (org.glassfish.internal.data.ProgressTracker)1