OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [gnu/] [java/] [security/] [x509/] [X509CRLSelectorImpl.java] - Blame information for rev 769

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 769 jeremybenn
/* X509CRLSelectorImpl.java -- implementation of an X509CRLSelector.
2
   Copyright (C) 2004  Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package gnu.java.security.x509;
40
 
41
import java.io.IOException;
42
 
43
import java.security.Principal;
44
import java.security.cert.CRL;
45
import java.security.cert.CRLSelector;
46
import java.security.cert.X509CRL;
47
 
48
import java.util.Collection;
49
import java.util.Collections;
50
import java.util.HashSet;
51
import java.util.Iterator;
52
import java.util.Set;
53
 
54
import javax.security.auth.x500.X500Principal;
55
 
56
/**
57
 * Sun's implementation of X509CRLSelector sucks. This one tries to work
58
 * better.
59
 */
60
public class X509CRLSelectorImpl implements CRLSelector
61
{
62
 
63
  // Fields.
64
  // -------------------------------------------------------------------------
65
 
66
  private Set issuerNames;
67
 
68
  // Constructor.
69
  // -------------------------------------------------------------------------
70
 
71
  public X509CRLSelectorImpl()
72
  {
73
    issuerNames = new HashSet();
74
  }
75
 
76
  // Instance methods.
77
  // -------------------------------------------------------------------------
78
 
79
  public void addIssuerName(byte[] issuerName) throws IOException
80
  {
81
    issuerNames.add(new X500DistinguishedName(issuerName));
82
  }
83
 
84
  public void addIssuerName(String issuerName)
85
  {
86
    issuerNames.add(new X500DistinguishedName(issuerName));
87
  }
88
 
89
  public void addIssuerName(Principal issuerName) throws IOException
90
  {
91
    if (issuerName instanceof X500DistinguishedName)
92
      issuerNames.add(issuerName);
93
    else if (issuerName instanceof X500Principal)
94
      issuerNames.add(new X500DistinguishedName(((X500Principal) issuerName).getEncoded()));
95
    else
96
      issuerNames.add(new X500DistinguishedName(issuerName.getName()));
97
  }
98
 
99
  public Collection getIssuerNames()
100
  {
101
    return Collections.unmodifiableSet(issuerNames);
102
  }
103
 
104
  public Object clone()
105
  {
106
    X509CRLSelectorImpl copy = new X509CRLSelectorImpl();
107
    copy.issuerNames.addAll(issuerNames);
108
    return copy;
109
  }
110
 
111
  public boolean match(CRL crl)
112
  {
113
    if (!(crl instanceof X509CRL))
114
      return false;
115
    try
116
      {
117
        Principal p = ((X509CRL) crl).getIssuerDN();
118
        X500DistinguishedName thisName = null;
119
        if (p instanceof X500DistinguishedName)
120
          thisName = (X500DistinguishedName) p;
121
        else if (p instanceof X500Principal)
122
          thisName = new X500DistinguishedName(((X500Principal) p).getEncoded());
123
        else
124
          thisName = new X500DistinguishedName(p.getName());
125
        for (Iterator it = issuerNames.iterator(); it.hasNext(); )
126
          {
127
            X500DistinguishedName name = (X500DistinguishedName) it.next();
128
            if (thisName.equals(name))
129
              return true;
130
          }
131
      }
132
    catch (Exception x)
133
      {
134
      }
135
    return false;
136
  }
137
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.