Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
BEGIN LICENSE BLOCK ***** Version: CPL 1.0/GPL 2.0/LGPL 2.1 The contents of this file are subject to the Common Public License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.eclipse.org/legal/cpl-v10.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyright (C) 2006 Ola Bini <ola@ologix.com> Alternatively, the contents of this file may be used under the terms of either of the GNU General Public License Version 2 or later (the "GPL"), or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in which case the provisions of the GPL or the LGPL are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of either the GPL or the LGPL, and not to allow others to use your version of this file under the terms of the CPL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL or the LGPL. If you do not delete the provisions above, a recipient may use your version of this file under the terms of any one of the CPL, the GPL or the LGPL. END LICENSE BLOCK ***
 
 package org.jruby.ext.openssl.x509store;
 
 
 import java.util.List;
 
c: X509_STORE

Author(s):
Ola Bini
 
 public class Store implements X509TrustManager {
     public int cache;
     public List<X509Objectobjs;
     public List<LookupcertificateMethods;
     public VerifyParameter param;
 
     public static interface VerifyFunction extends Function1 {
         public static final VerifyFunction EMPTY = new VerifyFunction(){
                 public int call(Object arg0) {
                     return -1;
                 }
             };
     }
     public static interface VerifyCallbackFunction extends Function2 {
         public static final VerifyCallbackFunction EMPTY = new VerifyCallbackFunction(){
                 public int call(Object arg0Object arg1) {
                     return -1;
                 }
             };
     }
     public static interface GetIssuerFunction extends Function3 {
         public static final GetIssuerFunction EMPTY = new GetIssuerFunction(){
                 public int call(Object arg0Object arg1Object arg2) {
                     return -1;
                 }
             };
     }
     public static interface CheckIssuedFunction extends Function3 {
         public static final CheckIssuedFunction EMPTY = new CheckIssuedFunction(){
                 public int call(Object arg0Object arg1Object arg2) {
                     return -1;
                 }
             };
     }
     public static interface CheckRevocationFunction extends Function1 {
         public static final CheckRevocationFunction EMPTY = new CheckRevocationFunction(){
                 public int call(Object arg0) {
                     return -1;
                 }
             };
     }
     public static interface GetCRLFunction extends Function3 {
         public static final GetCRLFunction EMPTY = new GetCRLFunction(){
                 public int call(Object arg0Object arg1Object arg2) {
                     return -1;
                 }
             };
     }
     public static interface CheckCRLFunction extends Function2 {
         public static final CheckCRLFunction EMPTY = new CheckCRLFunction(){
                 public int call(Object arg0Object arg1) {
                     return -1;
                 }
             };
     }
     public static interface CertificateCRLFunction extends Function3 {
         public static final CertificateCRLFunction EMPTY = new CertificateCRLFunction(){
                public int call(Object arg0Object arg1Object arg2) {
                    return -1;
                }
            };
    }
    public static interface CleanupFunction extends Function1 {
        public static final CleanupFunction EMPTY = new CleanupFunction(){
                public int call(Object arg0) {
                    return -1;
                }
            };
    }
    public VerifyFunction verify;
    public GetCRLFunction getCRL;
    public CheckCRLFunction checkCRL;
    public CleanupFunction cleanup;
    public List<ObjectextraData;
    public int references;

    
c: X509_STORE_new
    public Store() {
         = new ArrayList<X509Object>();
         = 1;
         = new ArrayList<Lookup>();
         = .;
         = new VerifyParameter();
        
         = .;
         = .;
         = .;
         = .;
         = 1;
         = new ArrayList<Object>();
        this..add(null);this..add(null);this..add(null);
        this..add(null);this..add(null);this..add(null);
        this..add(null);this..add(null);this..add(null);
    }

    
c: X509_STORE_set_verify_func
    public void setVerifyFunction(VerifyFunction func) {
         = func;
    }

    
c: X509_STORE_set_verify_cb_func
         = func;
    }

    
c: X509_STORE_free
    public void free() throws Exception {
        for(Lookup lu : ) {
            lu.shutdown();
            lu.free();
        }
        if( != null) {
            .free();
        }
    }

    
c: X509_set_ex_data
    public int setExtraData(int idx,Object data) { 
        .set(idx,data);
        return 1; 
    } 

    
c: X509_get_ex_data
    public Object getExtraData(int idx) { 
        return .get(idx); 
    }

    
c: X509_STORE_set_depth
    public int setDepth(int depth) { 
        .setDepth(depth);
        return 1;
    }

    
c: X509_STORE_set_flags
    public int setFlags(long flags) { 
        return .setFlags(flags);
    }

    
c: X509_STORE_set_purpose
    public int setPurpose(int purpose) { 
        return .setPurpose(purpose);
    }

    
c: X509_STORE_set_trust
    public int setTrust(int trust) { 
        return .setTrust(trust);
    }

    
c: X509_STORE_set1_param
    public int setParam(VerifyParameter pm) { 
        return .set();
    }

    
c: X509_STORE_add_lookup
    public Lookup addLookup(LookupMethod mthrows Exception { 
        Lookup lu;
        for(Lookup l : ) {
            if(l.equals(m)) {
                return l;
            }
        }
        lu = new Lookup(m);
        lu.store = this;
        .add(lu);
        return lu;
    } 

    
c: X509_STORE_add_cert
    public int addCertificate(X509Certificate x) { 
        int ret = 1;
        if(x == null) {
            return 0;
        }
        Certificate obj = new Certificate();
        obj.x509 = StoreContext.ensureAux(x);
        synchronized(.) {
            if(X509Object.retrieveMatch(,obj) != null) {
                X509Error.addError(.);
                ret=0;
            } else {
                .add(obj);
            }
        }
        return ret;
    } 

    
c: X509_STORE_add_crl
    public int addCRL(java.security.cert.CRL x) { 
        int ret = 1;
        if(null == x) {
            return 0;
        }
        CRL obj = new CRL();
        obj.crl = x;
        synchronized(.) {
            if(X509Object.retrieveMatch(,obj) != null) {
                X509Error.addError(.);
                ret=0;
            } else {
                .add(obj);
            }
        }
        return ret;
    } 

    
c: X509_STORE_load_locations
    public int loadLocations(String fileString paththrows Exception { 
        Lookup lookup;
        if(file != null) {
            lookup = addLookup(Lookup.fileLookup());
            if(lookup == null) {
                return 0;
            }
            if(lookup.loadFile(new CertificateFile.Path(file,.)) != 1) {
                return 0;
            }
        }
        if(path != null) {
            lookup = addLookup(Lookup.hashDirLookup());
            if(lookup == null) {
                return 0;
            }
            if(lookup.addDir(new CertificateHashDir.Dir(path,.)) != 1) {
                return 0;
            }
        }
        if((path == null) && (file == null)) {
            return 0;
        }
        return 1;
    } 

    
c: X509_STORE_set_default_paths
     
    public int setDefaultPaths() throws Exception { 
        Lookup lookup;
        lookup = addLookup(Lookup.fileLookup());
        if(lookup == null) {
            return 0;
        }
        try {
            lookup.loadFile(new CertificateFile.Path(null,.));
        }
        catch(FileNotFoundException e) {
            // set_default_paths ignores FileNotFound
        }
        lookup = addLookup(Lookup.hashDirLookup());
        if(lookup == null) {
            return 0;
        }
        try {
            lookup.addDir(new CertificateHashDir.Dir(null,.));
        }
        catch(FileNotFoundException e) {
            // set_default_paths ignores FileNotFound
        }
        X509Error.clearErrors();
        return 1;
    } 
    public void checkClientTrusted(X509Certificate[] chainString authType) {
    }
    public void checkServerTrusted(X509Certificate[] chainString authType) {
    }
    public X509Certificate[] getAcceptedIssuers() {
        List<X509Certificatel = new ArrayList<X509Certificate>();
        for(X509Object o : ) {
            if(o instanceof Certificate) {
                l.add(((Certificate)o).);
            }
        }
        return l.toArray(new X509Certificate[l.size()]);
    }
}// X509_STORE
New to GrepCode? Check out our FAQ X