/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This is a class which supplies several KeySelector implementations
*/
class KeySelectors {
/**
* KeySelector which would always return the secret key specified in its
* constructor.
*/
}
}
throws KeySelectorException {
return new SimpleKSResult(key);
}
return new SecretKey() {
return "RAW";
}
public String getAlgorithm() {
return "Secret key";
}
public byte[] getEncoded() {
}
};
}
}
/**
* KeySelector which would retrieve the X509Certificate out of the
* KeyInfo element and return the public key.
* NOTE: If there is an X509CRL in the KeyInfo element, then revoked
* certificate will be ignored.
*/
throws KeySelectorException {
throw new KeySelectorException("Null KeyInfo object!");
}
// search for X509Data in keyinfo
// Looking for CRL before finding certificates
}
}
boolean hasCRL = false;
// skip non-X509Certificate entries
if (o instanceof X509Certificate) {
continue;
} else {
return new SimpleKSResult
(((X509Certificate)o).getPublicKey());
}
}
}
}
}
throw new KeySelectorException("No X509Certificate found!");
}
}
/**
* KeySelector which would retrieve the public key out of the
* KeyValue element and return it.
* NOTE: If the key algorithm doesn't match signature algorithm,
* then the public key will be ignored.
*/
throws KeySelectorException {
throw new KeySelectorException("Null KeyInfo object!");
}
if (xmlStructure instanceof KeyValue) {
try {
} catch (KeyException ke) {
throw new KeySelectorException(ke);
}
// make sure algorithm is compatible with method
return new SimpleKSResult(pk);
}
}
}
throw new KeySelectorException("No KeyValue element found!");
}
return true;
("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256") ||
("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384") ||
("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"))) {
return true;
} else {
return false;
}
}
}
/**
* KeySelector which would perform special lookup as documented
* by the ie/baltimore/merlin-examples testcases and return the
* matching public key.
*/
try {
} catch (CertificateException ex) {
// not going to happen
}
}
}
switch (matchType) {
case MATCH_SUBJECT:
try {
matchResult.add(c);
}
} catch (IOException ioe) { }
break;
case MATCH_ISSUER:
try {
matchResult.add(c);
}
} catch (IOException ioe) { }
break;
case MATCH_SERIAL:
matchResult.add(c);
}
break;
case MATCH_SUBJECT_KEY_ID:
try {
matchResult.add(c);
}
} catch (IOException ex) { }
}
break;
case MATCH_CERTIFICATE:
matchResult.add(c);
}
break;
}
}
return matchResult;
}
throws KeySelectorException {
throw new KeySelectorException("Null KeyInfo object!");
}
try {
if (xmlStructure instanceof KeyName) {
// Lookup the public key using the key name 'Xxx',
} catch (FileNotFoundException e) {
// assume KeyName contains subject DN and search
// collection of certs for match
if (numOfMatches != 1) {
throw new KeySelectorException
" match found");
}
}
return new SimpleKSResult(pk);
} else if (xmlStructure instanceof RetrievalMethod) {
// Lookup the public key using the retrievel method.
// NOTE: only X509Certificate type is supported.
try (FileInputStream fis =
}
} else {
throw new KeySelectorException
("Unsupported RetrievalMethod type");
}
} else if (xmlStructure instanceof X509Data) {
// Lookup the public key using the information
// specified in X509Data element, i.e. searching
// over the collection of certificate files under
// "certs" subdirectory and return those match.
for (int k = 0; k<size; k++) {
} else if (obj instanceof byte[]) {
certs);
} else if (obj instanceof X509Certificate) {
} else if (obj instanceof X509IssuerSerial) {
} else {
}
}
if (numOfMatches != 1) {
throw new KeySelectorException
" match found");
}
}
throw new KeySelectorException(ex);
}
}
throw new KeySelectorException("No matching key found!");
}
}
static class ByteUtil {
char[] res = new char[2];
}
int numDumped = 0;
for (int j=0; j<(numBytesPerRow); j++) {
", ");
}
}
numDumped += 1;
}
}
}
}
}