| 1 |
/* |
| 2 |
* Copyright 1999-2010 University of Chicago |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 11 |
* express or implied. |
| 12 |
* |
| 13 |
* See the License for the specific language governing permissions and limitations under the License. |
| 14 |
*/ |
| 15 |
|
| 16 |
package org.globus.gsi.stores; |
| 17 |
|
| 18 |
import org.apache.commons.logging.Log; |
| 19 |
|
| 20 |
import org.apache.commons.logging.LogFactory; |
| 21 |
|
| 22 |
import java.io.File; |
| 23 |
import java.io.FilenameFilter; |
| 24 |
import java.security.cert.TrustAnchor; |
| 25 |
|
| 26 |
import org.globus.util.GlobusResource; |
| 27 |
|
| 28 |
|
| 29 |
/** |
| 30 |
* Created by IntelliJ IDEA. |
| 31 |
* User: turtlebender |
| 32 |
* Date: Dec 29, 2009 |
| 33 |
* Time: 11:49:20 AM |
| 34 |
* To change this template use File | Settings | File Templates. |
| 35 |
*/ |
| 36 |
public class ResourceCACertStore extends ResourceSecurityWrapperStore<ResourceTrustAnchor, TrustAnchor> { |
| 37 |
|
| 38 |
private static FilenameFilter filter = new TrustAnchorFilter(); |
| 39 |
private Log logger = LogFactory.getLog(getClass().getCanonicalName()); |
| 40 |
|
| 41 |
@Override |
| 42 |
public ResourceTrustAnchor create(GlobusResource globusResource) throws ResourceStoreException { |
| 43 |
return new ResourceTrustAnchor(false, globusResource); |
| 44 |
} |
| 45 |
|
| 46 |
@Override |
| 47 |
protected Log getLog() { |
| 48 |
return logger; |
| 49 |
} |
| 50 |
|
| 51 |
@Override |
| 52 |
public FilenameFilter getDefaultFilenameFilter() { |
| 53 |
return filter; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* File filter for determining a Trust Anchor |
| 58 |
*/ |
| 59 |
public static class TrustAnchorFilter implements FilenameFilter { |
| 60 |
|
| 61 |
public boolean accept(File dir, String file) { |
| 62 |
|
| 63 |
if (file == null) { |
| 64 |
throw new IllegalArgumentException(); |
| 65 |
} |
| 66 |
int length = file.length(); |
| 67 |
return length > 2 |
| 68 |
&& file.charAt(length - 2) == '.' |
| 69 |
&& file.charAt(length - 1) >= '0' |
| 70 |
&& file.charAt(length - 1) <= '9'; |
| 71 |
} |
| 72 |
} |
| 73 |
} |