src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/DEREncodedKeyValueResolver.java
changeset 50614 3810c9a2efa1
parent 47216 71c04702a3d5
equal deleted inserted replaced
50613:0f93a75b9213 50614:3810c9a2efa1
     1 /*
     1 /*
     2  * reserved comment block
     2  * reserved comment block
     3  * DO NOT REMOVE OR ALTER!
     3  * DO NOT REMOVE OR ALTER!
       
     4  */
       
     5 /**
       
     6  * Licensed to the Apache Software Foundation (ASF) under one
       
     7  * or more contributor license agreements. See the NOTICE file
       
     8  * distributed with this work for additional information
       
     9  * regarding copyright ownership. The ASF licenses this file
       
    10  * to you under the Apache License, Version 2.0 (the
       
    11  * "License"); you may not use this file except in compliance
       
    12  * with the License. You may obtain a copy of the License at
       
    13  *
       
    14  * http://www.apache.org/licenses/LICENSE-2.0
       
    15  *
       
    16  * Unless required by applicable law or agreed to in writing,
       
    17  * software distributed under the License is distributed on an
       
    18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
       
    19  * KIND, either express or implied. See the License for the
       
    20  * specific language governing permissions and limitations
       
    21  * under the License.
     4  */
    22  */
     5 package com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations;
    23 package com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations;
     6 
    24 
     7 import java.security.PrivateKey;
    25 import java.security.PrivateKey;
     8 import java.security.PublicKey;
    26 import java.security.PublicKey;
    19 import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
    37 import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
    20 import org.w3c.dom.Element;
    38 import org.w3c.dom.Element;
    21 
    39 
    22 /**
    40 /**
    23  * KeyResolverSpi implementation which resolves public keys from a
    41  * KeyResolverSpi implementation which resolves public keys from a
    24  * <code>dsig11:DEREncodedKeyValue</code> element.
    42  * {@code dsig11:DEREncodedKeyValue} element.
    25  *
    43  *
    26  * @author Brent Putman (putmanb@georgetown.edu)
       
    27  */
    44  */
    28 public class DEREncodedKeyValueResolver extends KeyResolverSpi {
    45 public class DEREncodedKeyValueResolver extends KeyResolverSpi {
    29 
    46 
    30     /** {@link org.apache.commons.logging} logging facility */
    47     private static final com.sun.org.slf4j.internal.Logger LOG =
    31     private static java.util.logging.Logger log =
    48         com.sun.org.slf4j.internal.LoggerFactory.getLogger(DEREncodedKeyValueResolver.class);
    32         java.util.logging.Logger.getLogger(DEREncodedKeyValueResolver.class.getName());
       
    33 
    49 
    34     /** {@inheritDoc}. */
    50     /** {{@inheritDoc}}. */
    35     public boolean engineCanResolve(Element element, String baseURI, StorageResolver storage) {
    51     public boolean engineCanResolve(Element element, String baseURI, StorageResolver storage) {
    36         return XMLUtils.elementIsInSignature11Space(element, Constants._TAG_DERENCODEDKEYVALUE);
    52         return XMLUtils.elementIsInSignature11Space(element, Constants._TAG_DERENCODEDKEYVALUE);
    37     }
    53     }
    38 
    54 
    39     /** {@inheritDoc}. */
    55     /** {{@inheritDoc}}. */
    40     public PublicKey engineLookupAndResolvePublicKey(Element element, String baseURI, StorageResolver storage)
    56     public PublicKey engineLookupAndResolvePublicKey(Element element, String baseURI, StorageResolver storage)
    41         throws KeyResolverException {
    57         throws KeyResolverException {
    42 
    58 
    43         if (log.isLoggable(java.util.logging.Level.FINE)) {
    59         LOG.debug("Can I resolve {}", element.getTagName());
    44             log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName());
       
    45         }
       
    46 
    60 
    47         if (!engineCanResolve(element, baseURI, storage)) {
    61         if (!engineCanResolve(element, baseURI, storage)) {
    48             return null;
    62             return null;
    49         }
    63         }
    50 
    64 
    51         try {
    65         try {
    52             DEREncodedKeyValue derKeyValue = new DEREncodedKeyValue(element, baseURI);
    66             DEREncodedKeyValue derKeyValue = new DEREncodedKeyValue(element, baseURI);
    53             return derKeyValue.getPublicKey();
    67             return derKeyValue.getPublicKey();
    54         } catch (XMLSecurityException e) {
    68         } catch (XMLSecurityException e) {
    55             if (log.isLoggable(java.util.logging.Level.FINE)) {
    69             LOG.debug("XMLSecurityException", e);
    56                 log.log(java.util.logging.Level.FINE, "XMLSecurityException", e);
       
    57             }
       
    58         }
    70         }
    59 
    71 
    60         return null;
    72         return null;
    61     }
    73     }
    62 
    74 
    63     /** {@inheritDoc}. */
    75     /** {{@inheritDoc}}. */
    64     public X509Certificate engineLookupResolveX509Certificate(Element element, String baseURI, StorageResolver storage)
    76     public X509Certificate engineLookupResolveX509Certificate(Element element, String baseURI, StorageResolver storage)
    65         throws KeyResolverException {
    77         throws KeyResolverException {
    66         return null;
    78         return null;
    67     }
    79     }
    68 
    80 
    69     /** {@inheritDoc}. */
    81     /** {{@inheritDoc}}. */
    70     public SecretKey engineLookupAndResolveSecretKey(Element element, String baseURI, StorageResolver storage)
    82     public SecretKey engineLookupAndResolveSecretKey(Element element, String baseURI, StorageResolver storage)
    71         throws KeyResolverException {
    83         throws KeyResolverException {
    72         return null;
    84         return null;
    73     }
    85     }
    74 
    86 
    75     /** {@inheritDoc}. */
    87     /** {{@inheritDoc}}. */
    76     public PrivateKey engineLookupAndResolvePrivateKey(Element element, String baseURI, StorageResolver storage)
    88     public PrivateKey engineLookupAndResolvePrivateKey(Element element, String baseURI, StorageResolver storage)
    77         throws KeyResolverException {
    89         throws KeyResolverException {
    78         return null;
    90         return null;
    79     }
    91     }
    80 
    92