View Javadoc
1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied. See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.wss4j.stax.impl.securityToken;
20  
21  import java.security.Key;
22  import java.security.PublicKey;
23  import java.security.cert.X509Certificate;
24  import java.util.Deque;
25  import java.util.Map;
26  
27  import org.apache.wss4j.stax.ext.WSInboundSecurityContext;
28  import org.apache.wss4j.stax.securityToken.SecurityTokenReference;
29  import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
30  import org.apache.xml.security.exceptions.XMLSecurityException;
31  import org.apache.xml.security.stax.ext.XMLSecurityConstants;
32  import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
33  import org.apache.xml.security.stax.impl.securityToken.AbstractInboundSecurityToken;
34  import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
35  
36  public class SecurityTokenReferenceImpl extends AbstractInboundSecurityToken implements SecurityTokenReference {
37  
38      private final InboundSecurityToken inboundSecurityToken;
39      private final Deque<XMLSecEvent> xmlSecEvents;
40  
41      public SecurityTokenReferenceImpl(InboundSecurityToken inboundSecurityToken, Deque<XMLSecEvent> xmlSecEvents,
42                                        WSInboundSecurityContext wsInboundSecurityContext, String id,
43                                        WSSecurityTokenConstants.KeyIdentifier keyIdentifier) {
44          super(wsInboundSecurityContext, id, keyIdentifier, true);
45          this.inboundSecurityToken = inboundSecurityToken;
46          this.xmlSecEvents = xmlSecEvents;
47      }
48  
49      public Deque<XMLSecEvent> getXmlSecEvents() {
50          return xmlSecEvents;
51      }
52  
53      @Override
54      public boolean isAsymmetric() throws XMLSecurityException {
55          return inboundSecurityToken.isAsymmetric();
56      }
57  
58      @Override
59      public Map<String, Key> getSecretKey() throws XMLSecurityException {
60          return inboundSecurityToken.getSecretKey();
61      }
62  
63      @Override
64      protected Key getKey(String algorithmURI, XMLSecurityConstants.AlgorithmUsage algorithmUsage,
65                           String correlationID) throws XMLSecurityException {
66          return inboundSecurityToken.getSecretKey(algorithmURI, algorithmUsage, correlationID);
67      }
68  
69      @Override
70      public PublicKey getPublicKey() throws XMLSecurityException {
71          return inboundSecurityToken.getPublicKey();
72      }
73  
74      @Override
75      protected PublicKey getPubKey(String algorithmURI, XMLSecurityConstants.AlgorithmUsage algorithmUsage,
76                                    String correlationID) throws XMLSecurityException {
77          return inboundSecurityToken.getPublicKey(algorithmURI, algorithmUsage, correlationID);
78      }
79  
80      @Override
81      public X509Certificate[] getX509Certificates() throws XMLSecurityException {
82          return inboundSecurityToken.getX509Certificates();
83      }
84  
85      @Override
86      public void verify() throws XMLSecurityException {
87          inboundSecurityToken.verify();
88      }
89  
90      @Override
91      public InboundSecurityToken getKeyWrappingToken() throws XMLSecurityException {
92          return (InboundSecurityToken)inboundSecurityToken.getKeyWrappingToken();
93      }
94  
95      @Override
96      public boolean isIncludedInMessage() {
97          return inboundSecurityToken.isIncludedInMessage();
98      }
99  
100     @Override
101     public WSSecurityTokenConstants.TokenType getTokenType() {
102         return inboundSecurityToken.getTokenType();
103     }
104 }