~ubuntu-branches/ubuntu/precise/libxml-security-java/precise-security

« back to all changes in this revision

Viewing changes to src_unitTests/javax/xml/crypto/test/KeySelectors.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-08-30 14:07:46 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: package-import@ubuntu.com-20110830140746-wfmiluk1yddqd6ch
* New upstream release
* Update debian/watch to point to new SVN repo.
* Update Standards-Version: 3.9.1.
* Switch to source format 3.0.
* Use Maven to build the package. Ignore test failures.
* Update Description.
* Add a documentation package.
* Update Homepage field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2006-2009 The Apache Software Foundation.
 
2
 * Copyright 2006-2010 The Apache Software Foundation.
3
3
 *
4
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
5
5
 *  you may not use this file except in compliance with the License.
27
27
import javax.xml.crypto.dsig.*;
28
28
import javax.xml.crypto.dsig.keyinfo.*;
29
29
import javax.crypto.SecretKey;
30
 
import sun.security.util.DerValue;
31
 
import sun.security.x509.X500Name;
32
30
 
33
31
 
34
32
/**
108
106
                        }
109
107
                    }
110
108
                    Iterator xi = xd.getContent().iterator();
111
 
                    boolean hasCRL = false;
112
109
                    while (xi.hasNext()) {
113
110
                        Object o = xi.next();
114
111
                        // skip non-X509Certificate entries
217
214
            Vector matchResult = new Vector();
218
215
            for (int j=0; j < pool.size(); j++) {
219
216
                X509Certificate c = (X509Certificate) pool.get(j);
 
217
                
220
218
                switch (matchType) {
221
219
                case MATCH_SUBJECT:
222
 
                    try {
223
 
                        if (c.getSubjectDN().equals(new X500Name((String)value))) {
 
220
                    Principal p1 = new javax.security.auth.x500.X500Principal((String)value);
 
221
                if (c.getSubjectX500Principal().equals(p1)) {
224
222
                            matchResult.add(c);
225
 
                        }
226
 
                    } catch (IOException ioe) { }
 
223
                }
227
224
                    break;
228
225
                case MATCH_ISSUER:
229
 
                    try {
230
 
                        if (c.getIssuerDN().equals(new X500Name((String)value))) {
 
226
                    Principal p2 = new javax.security.auth.x500.X500Principal((String)value);
 
227
                if (c.getIssuerX500Principal().equals(p2)) {
231
228
                            matchResult.add(c);
232
 
                        }
233
 
                    } catch (IOException ioe) { }
 
229
                }
234
230
                    break;
235
231
                case MATCH_SERIAL:
236
232
                    if (c.getSerialNumber().equals(value)) {
241
237
                case MATCH_SUBJECT_KEY_ID:
242
238
                    byte[] extension = c.getExtensionValue("2.5.29.14");
243
239
                    if (extension != null) {
244
 
                        try {
245
 
                            DerValue derValue = new DerValue(extension);
246
 
                            DerValue derValue2 = new DerValue(derValue.getOctetString());
247
 
                            byte[] extVal = derValue2.getOctetString();
 
240
                            byte extVal[] = new byte[extension.length - 4];
 
241
                            System.arraycopy(extension, 4, extVal, 0, extVal.length);
248
242
                            
249
243
                            if (Arrays.equals(extVal, (byte[]) value)) {
250
 
                                matchResult.add(c);
 
244
                                matchResult.add(c);
251
245
                            }
252
 
                        } catch (IOException ex) { }
253
246
                    }
254
247
                    break;
255
248
                case MATCH_CERTIFICATE: