ProfileValidators.java 2.82 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Reference
 *  org.apache.felix.scr.annotations.ReferenceCardinality
 *  org.apache.felix.scr.annotations.ReferencePolicy
 *  org.apache.felix.scr.annotations.Service
 */
package com.adobe.granite.auth.oauth.impl;

import com.adobe.granite.auth.oauth.ProfileValidator;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
@Component(immediate=1)
@Service(value={ProfileValidators.class})
@Reference(name="profileValidator", referenceInterface=ProfileValidator.class, bind="bindProfileValidator", unbind="unbindProfileValidator", cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, policy=ReferencePolicy.DYNAMIC)
public class ProfileValidators {
    private final ReadWriteLock lock = new ReentrantReadWriteLock();
    private final List<ProfileValidator> profileValidators = new ArrayList<ProfileValidator>();

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public boolean isValidProfile(String providerId, String userId, Map<String, Object> profileData) {
        this.lock.readLock().lock();
        try {
            for (ProfileValidator profileValidator : this.profileValidators) {
                if (!profileValidator.getId().equals(providerId) || profileValidator.isValidProfile(userId, profileData)) continue;
                boolean bl = false;
                return bl;
            }
        }
        finally {
            this.lock.readLock().unlock();
        }
        return true;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    protected void bindProfileValidator(ProfileValidator profileValidator) {
        this.lock.writeLock().lock();
        try {
            this.profileValidators.add(profileValidator);
        }
        finally {
            this.lock.writeLock().unlock();
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    protected void unbindProfileValidator(ProfileValidator profileValidator) {
        this.lock.writeLock().lock();
        try {
            this.profileValidators.remove(profileValidator);
        }
        finally {
            this.lock.writeLock().unlock();
        }
    }
}