Search in sources :

Example 6 with X509AttributeCertStoreSelector

use of com.github.zhenwei.provider.x509.X509AttributeCertStoreSelector in project LinLong-Java by zhenwei1108.

the class LDAPStoreHelper method getAACertificates.

/**
 * Returns attribute certificates for an attribute authority
 * <p>
 * The aAcertificate holds the privileges of an attribute authority.
 * </p>
 *
 * @param selector The selector to find the attribute certificates.
 * @return A possible empty collection with attribute certificates.
 * @throws StoreException
 */
public Collection getAACertificates(X509AttributeCertStoreSelector selector) throws StoreException {
    String[] attrs = splitString(params.getAACertificateAttribute());
    String[] attrNames = splitString(params.getLdapAACertificateAttributeName());
    String[] subjectAttributeNames = splitString(params.getAACertificateSubjectAttributeName());
    List list = attrCertSubjectSerialSearch(selector, attrs, attrNames, subjectAttributeNames);
    Set resultSet = createAttributeCertificates(list, selector);
    if (resultSet.size() == 0) {
        X509AttributeCertStoreSelector emptySelector = new X509AttributeCertStoreSelector();
        list = attrCertSubjectSerialSearch(emptySelector, attrs, attrNames, subjectAttributeNames);
        resultSet.addAll(createAttributeCertificates(list, selector));
    }
    return resultSet;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) X509AttributeCertStoreSelector(com.github.zhenwei.provider.x509.X509AttributeCertStoreSelector) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with X509AttributeCertStoreSelector

use of com.github.zhenwei.provider.x509.X509AttributeCertStoreSelector in project LinLong-Java by zhenwei1108.

the class LDAPStoreHelper method getAttributeCertificateAttributes.

/**
 * Returns an attribute certificate for an user.
 * <p>
 * The attributeCertificateAttribute holds the privileges of a user
 * </p>
 *
 * @param selector The selector to find the attribute certificates.
 * @return A possible empty collection with attribute certificates.
 * @throws StoreException
 */
public Collection getAttributeCertificateAttributes(X509AttributeCertStoreSelector selector) throws StoreException {
    String[] attrs = splitString(params.getAttributeCertificateAttributeAttribute());
    String[] attrNames = splitString(params.getLdapAttributeCertificateAttributeAttributeName());
    String[] subjectAttributeNames = splitString(params.getAttributeCertificateAttributeSubjectAttributeName());
    List list = attrCertSubjectSerialSearch(selector, attrs, attrNames, subjectAttributeNames);
    Set resultSet = createAttributeCertificates(list, selector);
    if (resultSet.size() == 0) {
        X509AttributeCertStoreSelector emptySelector = new X509AttributeCertStoreSelector();
        list = attrCertSubjectSerialSearch(emptySelector, attrs, attrNames, subjectAttributeNames);
        resultSet.addAll(createAttributeCertificates(list, selector));
    }
    return resultSet;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) X509AttributeCertStoreSelector(com.github.zhenwei.provider.x509.X509AttributeCertStoreSelector) ArrayList(java.util.ArrayList) List(java.util.List)

Example 8 with X509AttributeCertStoreSelector

use of com.github.zhenwei.provider.x509.X509AttributeCertStoreSelector in project LinLong-Java by zhenwei1108.

the class X509StoreLDAPAttrCerts method engineGetMatches.

/**
 * Returns a collection of matching attribute certificates from the LDAP location.
 * <p>
 * The selector must be a of type
 * <code>X509AttributeCertStoreSelector</code>. If it is not an empty
 * collection is returned.
 * </p>
 * <p>
 * The subject and the serial number should be reasonable criterias for a selector.
 * </p>
 *
 * @param selector The selector to use for finding.
 * @return A collection with the matches.
 * @throws StoreException if an exception occurs while searching.
 */
public Collection engineGetMatches(Selector selector) throws StoreException {
    if (!(selector instanceof X509AttributeCertStoreSelector)) {
        return Collections.EMPTY_SET;
    }
    X509AttributeCertStoreSelector xselector = (X509AttributeCertStoreSelector) selector;
    Set set = new HashSet();
    set.addAll(helper.getAACertificates(xselector));
    set.addAll(helper.getAttributeCertificateAttributes(xselector));
    set.addAll(helper.getAttributeDescriptorCertificates(xselector));
    return set;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) X509AttributeCertStoreSelector(com.github.zhenwei.provider.x509.X509AttributeCertStoreSelector) HashSet(java.util.HashSet)

Aggregations

Set (java.util.Set)7 X509AttributeCertStoreSelector (com.github.zhenwei.provider.x509.X509AttributeCertStoreSelector)6 HashSet (java.util.HashSet)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 X509AttributeCertificate (com.github.zhenwei.provider.x509.X509AttributeCertificate)3 Iterator (java.util.Iterator)3 Selector (com.github.zhenwei.core.util.Selector)2 PKIXExtendedParameters (com.github.zhenwei.provider.jcajce.PKIXExtendedParameters)2 ExtendedPKIXParameters (com.github.zhenwei.provider.x509.ExtendedPKIXParameters)2 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)2 X509Certificate (java.security.cert.X509Certificate)2 LinkedHashSet (java.util.LinkedHashSet)2 PKIXCertStoreSelector (com.github.zhenwei.provider.jcajce.PKIXCertStoreSelector)1 PKIXExtendedBuilderParameters (com.github.zhenwei.provider.jcajce.PKIXExtendedBuilderParameters)1 ExtCertPathBuilderException (com.github.zhenwei.provider.jce.exception.ExtCertPathBuilderException)1 ExtCertPathValidatorException (com.github.zhenwei.provider.jce.exception.ExtCertPathValidatorException)1 X509AttrCertParser (com.github.zhenwei.provider.jce.provider.X509AttrCertParser)1 ExtendedPKIXBuilderParameters (com.github.zhenwei.provider.x509.ExtendedPKIXBuilderParameters)1 PKIXAttrCertChecker (com.github.zhenwei.provider.x509.PKIXAttrCertChecker)1