Search in sources :

Example 1 with CNonceCache

use of org.glassfish.security.common.CNonceCache in project Payara by payara.

the class CNonceCacheFactoryImpl method createCNonceCache.

@Override
public CNonceCache createCNonceCache(String appName, String clusterName, String instanceName, String storeName) {
    boolean haEnabled = (clusterName != null) && (instanceName != null) && (storeName != null);
    CNonceCache cache = null;
    Map<String, String> map = new HashMap<String, String>();
    if (haEnabled) {
        cache = cHANonceCacheProvider.get();
        map.put(CLUSTER_NAME_PROP, clusterName);
        map.put(INSTANCE_NAME_PROP, instanceName);
    } else {
        cache = cNonceCacheProvider.get();
    }
    if (cache != null) {
        cache.init(cnonceCacheSize, storeName, nonceValidity, map);
    }
    return cache;
}
Also used : HashMap(java.util.HashMap) CNonceCache(org.glassfish.security.common.CNonceCache)

Example 2 with CNonceCache

use of org.glassfish.security.common.CNonceCache in project Payara by payara.

the class SecurityDeployer method cleanArtifacts.

// removes security policy if needed
@Override
protected void cleanArtifacts(DeploymentContext context) throws DeploymentException {
    removePolicy(context);
    SecurityUtil.removeRoleMapper(context);
    OpsParams params = context.getCommandParameters(OpsParams.class);
    if (this.appCnonceMap != null) {
        CNonceCache cache = appCnonceMap.remove(params.name());
        if (cache != null) {
            cache.destroy();
        }
    }
}
Also used : OpsParams(org.glassfish.api.deployment.OpsParams) CNonceCache(org.glassfish.security.common.CNonceCache)

Example 3 with CNonceCache

use of org.glassfish.security.common.CNonceCache in project Payara by payara.

the class SecurityDeployer method handleCNonceCacheBSInit.

private void handleCNonceCacheBSInit(String appName, Set<WebBundleDescriptor> webDesc, boolean isHA) {
    boolean hasDigest = false;
    for (WebBundleDescriptor webBD : webDesc) {
        LoginConfiguration lc = webBD.getLoginConfiguration();
        if (lc != null && LoginConfiguration.DIGEST_AUTHENTICATION.equals(lc.getAuthenticationMethod())) {
            hasDigest = true;
            break;
        }
    }
    if (!hasDigest) {
        return;
    }
    // initialize the backing stores as well for cnonce cache.
    if (isHaEnabled() && isHA) {
        final String clusterName = haUtil.getClusterName();
        final String instanceName = haUtil.getInstanceName();
        if (cnonceCacheFactory != null) {
            CNonceCache cache = cnonceCacheFactory.createCNonceCache(appName, clusterName, instanceName, HA_CNONCE_BS_NAME);
            this.appCnonceMap.put(appName, cache);
        }
    }
}
Also used : WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) LoginConfiguration(com.sun.enterprise.deployment.web.LoginConfiguration) CNonceCache(org.glassfish.security.common.CNonceCache)

Example 4 with CNonceCache

use of org.glassfish.security.common.CNonceCache in project Payara by payara.

the class CNonceCacheFactoryImpl method createCNonceCache.

@Override
public CNonceCache createCNonceCache(String appName, String clusterName, String instanceName, String storeName) {
    boolean haEnabled = (clusterName != null) && (instanceName != null) && (storeName != null);
    CNonceCache cache = null;
    Map<String, String> map = new HashMap<String, String>();
    if (haEnabled) {
        cache = cHANonceCacheProvider.get();
        map.put(CLUSTER_NAME_PROP, clusterName);
        map.put(INSTANCE_NAME_PROP, instanceName);
    } else {
        cache = cNonceCacheProvider.get();
    }
    if (cache != null) {
        cache.init(cnonceCacheSize, storeName, nonceValidity, map);
    }
    return cache;
}
Also used : HashMap(java.util.HashMap) CNonceCache(org.glassfish.security.common.CNonceCache)

Aggregations

CNonceCache (org.glassfish.security.common.CNonceCache)4 HashMap (java.util.HashMap)2 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)1 LoginConfiguration (com.sun.enterprise.deployment.web.LoginConfiguration)1 OpsParams (org.glassfish.api.deployment.OpsParams)1