0N/A/*
0N/A * reserved comment block
0N/A * DO NOT REMOVE OR ALTER!
0N/A */
0N/A/*
0N/A * Copyright 1999-2004 The Apache Software Foundation.
0N/A *
0N/A * Licensed under the Apache License, Version 2.0 (the "License");
0N/A * you may not use this file except in compliance with the License.
0N/A * You may obtain a copy of the License at
0N/A *
0N/A * http://www.apache.org/licenses/LICENSE-2.0
0N/A *
0N/A * Unless required by applicable law or agreed to in writing, software
0N/A * distributed under the License is distributed on an "AS IS" BASIS,
0N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0N/A * See the License for the specific language governing permissions and
0N/A * limitations under the License.
0N/A *
0N/A */
0N/Apackage com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations;
0N/A
0N/A
0N/A
0N/Aimport java.security.PublicKey;
0N/Aimport java.security.cert.X509Certificate;
0N/A
0N/A
0N/Aimport com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
0N/Aimport com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue;
0N/Aimport com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi;
0N/Aimport com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver;
0N/Aimport com.sun.org.apache.xml.internal.security.utils.Constants;
0N/Aimport com.sun.org.apache.xml.internal.security.utils.XMLUtils;
0N/Aimport org.w3c.dom.Element;
0N/A
0N/A
0N/A/**
0N/A *
661N/A * @author $Author: mullan $
0N/A */
0N/Apublic class RSAKeyValueResolver extends KeyResolverSpi {
0N/A
0N/A /** {@link java.util.logging} logging facility */
0N/A static java.util.logging.Logger log =
0N/A java.util.logging.Logger.getLogger(
0N/A RSAKeyValueResolver.class.getName());
0N/A
0N/A /** Field _rsaKeyElement */
661N/A
0N/A
0N/A /** @inheritDoc */
661N/A public PublicKey engineLookupAndResolvePublicKey(
661N/A Element element, String BaseURI, StorageResolver storage) {
661N/A if (log.isLoggable(java.util.logging.Level.FINE))
661N/A log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName());
0N/A if (element == null) {
661N/A return null;
0N/A }
0N/A
661N/A boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element,
661N/A Constants._TAG_KEYVALUE);
661N/A Element rsaKeyElement=null;
661N/A if (isKeyValue) {
661N/A rsaKeyElement = XMLUtils.selectDsNode(element.getFirstChild(),
661N/A Constants._TAG_RSAKEYVALUE, 0);
661N/A } else if (XMLUtils.elementIsInSignatureSpace(element,
661N/A Constants._TAG_RSAKEYVALUE)) {
0N/A // this trick is needed to allow the RetrievalMethodResolver to eat a
0N/A // ds:RSAKeyValue directly (without KeyValue)
661N/A rsaKeyElement = element;
661N/A }
0N/A
0N/A
661N/A if (rsaKeyElement == null) {
661N/A return null;
0N/A }
0N/A
0N/A try {
661N/A RSAKeyValue rsaKeyValue = new RSAKeyValue(rsaKeyElement,
0N/A BaseURI);
0N/A
0N/A return rsaKeyValue.getPublicKey();
0N/A } catch (XMLSecurityException ex) {
661N/A log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
0N/A }
0N/A
0N/A return null;
0N/A }
0N/A
0N/A /** @inheritDoc */
661N/A public X509Certificate engineLookupResolveX509Certificate(
0N/A Element element, String BaseURI, StorageResolver storage) {
0N/A return null;
0N/A }
0N/A
0N/A /** @inheritDoc */
661N/A public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
0N/A Element element, String BaseURI, StorageResolver storage) {
0N/A return null;
0N/A }
0N/A}