EncapsulatedTokenJaasHelper.java 1.97 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.granite.oauth.jwt.JwsValidator
 *  org.apache.felix.jaas.LoginModuleFactory
 *  org.osgi.framework.BundleContext
 *  org.osgi.framework.ServiceRegistration
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.day.crx.security.token.impl;

import com.adobe.granite.oauth.jwt.JwsValidator;
import com.day.crx.security.token.impl.EncapsulatedTokenLoginModuleFactory;
import java.util.Dictionary;
import java.util.Properties;
import org.apache.felix.jaas.LoginModuleFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

final class EncapsulatedTokenJaasHelper {
    private JwsValidator jwsValidator;
    private static final Logger log = LoggerFactory.getLogger(EncapsulatedTokenJaasHelper.class);
    private ServiceRegistration factoryRegistration;

    public EncapsulatedTokenJaasHelper(JwsValidator jwsValidator) {
        this.jwsValidator = jwsValidator;
    }

    public void open(BundleContext ctx, Dictionary properties) {
        Properties props = new Properties();
        props.put("jaas.ranking", properties.get("jaas.ranking"));
        props.put("jaas.controlFlag", properties.get("jaas.controlFlag"));
        props.put("jaas.realmName", properties.get("jaas.realmName"));
        this.factoryRegistration = ctx.registerService(LoginModuleFactory.class.getName(), (Object)new EncapsulatedTokenLoginModuleFactory(this.jwsValidator), (Dictionary)props);
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public void close() {
        if (this.factoryRegistration != null) {
            try {
                this.factoryRegistration.unregister();
            }
            finally {
                this.factoryRegistration = null;
            }
        }
    }

    public boolean enabled() {
        return this.factoryRegistration != null;
    }
}