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  
20  package org.apache.ws.security.conversation;
21  
22  import javax.xml.namespace.QName;
23  
24  /**
25   * Class ConversationConstants
26   */
27  public final class ConversationConstants {
28  
29      public static final int VERSION_05_02 = 1;
30      
31      public static final int VERSION_05_12 = 2;
32      
33      public static final int DEFAULT_VERSION = VERSION_05_02; 
34      
35      /**
36       * WS-SecConv Feb 2005 version
37       */
38      public static final String WSC_NS_05_02 = "http://schemas.xmlsoap.org/ws/2005/02/sc"; 
39      
40      /**
41       * WS-Sx version
42       */
43      public static final String WSC_NS_05_12 = 
44          "http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512";
45      
46      /**
47       * Token type of DerivedKeyToken
48       */
49      public static final String TOKEN_TYPE_DERIVED_KEY_TOKEN =  "/dk";
50      
51      /**
52       * Token type of SecurityContextToken
53       */
54      public static final String TOKEN_TYPE_SECURITY_CONTEXT_TOKEN = "/sct";
55      
56      /**
57       * Field WSC_PREFIX
58       */
59      public static final String WSC_PREFIX = "wsc";
60  
61      /**
62       * Field SECURITY_CONTEXT_TOKEN_LN
63       */
64      public static final String SECURITY_CONTEXT_TOKEN_LN =
65              "SecurityContextToken";
66  
67      /**
68       * Field IDENTIFIER_LN
69       */
70      public static final String IDENTIFIER_LN = "Identifier";
71  
72      /**
73       * Field EXPIRES_LN
74       */
75      public static final String EXPIRES_LN = "Expires";
76  
77      /**
78       * Field KEYS_LN
79       */
80      public static final String KEYS_LN = "Keys";
81  
82      /**
83       * Field SECURITY_TOKEN_REFERENCE_LN
84       */
85      public static final String SECURITY_TOKEN_REFERENCE_LN =
86              "SecurityTokenReference";
87  
88      /**
89       * Field DERIVED_KEY_TOKEN_LN
90       */
91      public static final String DERIVED_KEY_TOKEN_LN = "DerivedKeyToken";
92  
93      /**
94       * Field PROPERTIES_LN
95       */
96      public static final String PROPERTIES_LN = "Properties";
97  
98      /**
99       * Field LENGTH_LN
100      */
101     public static final String LENGTH_LN = "Length";
102 
103     /**
104      * Field GENERATION_LN
105      */
106     public static final String GENERATION_LN = "Generation";
107 
108     /**
109      * Field OFFSET_LN
110      */
111     public static final String OFFSET_LN = "Offset";
112 
113     /**
114      * Field LABEL_LN
115      */
116     public static final String LABEL_LN = "Label";
117 
118     /**
119      * Field NONCE_LN
120      */
121     public static final String NONCE_LN = "Nonce";
122 
123     public static final int DIRECT_GENERATED = 1;
124     public static final int STS_GENERATED = 2;
125     public static final int STSREQUEST_TOKEN = 3;
126     public static final int INTEROP_SCENE1 = 4;
127 
128     public static final String IDENTIFIER = "SCT_Identifier";
129 
130     public static final int DK_SIGN = 1;
131     public static final int DK_ENCRYPT = 2;
132     
133     public static final String DEFAULT_LABEL = "WS-SecureConversation";
134     
135     public static final QName SECURITY_CTX_TOKEN_QNAME_05_02 =
136         new QName(
137             ConversationConstants.WSC_NS_05_02, 
138             ConversationConstants.SECURITY_CONTEXT_TOKEN_LN
139         );
140     
141     public static final QName SECURITY_CTX_TOKEN_QNAME_05_12 =
142         new QName(
143             ConversationConstants.WSC_NS_05_12, 
144             ConversationConstants.SECURITY_CONTEXT_TOKEN_LN
145         );
146 
147     public static final QName DERIVED_KEY_TOKEN_QNAME_05_02 =
148         new QName(
149             ConversationConstants.WSC_NS_05_02, 
150             ConversationConstants.DERIVED_KEY_TOKEN_LN
151         );
152     
153     public static final QName DERIVED_KEY_TOKEN_QNAME_05_12 =
154         new QName(
155             ConversationConstants.WSC_NS_05_12, 
156             ConversationConstants.DERIVED_KEY_TOKEN_LN
157         );
158     
159     /**
160      * Key to hold the map of security context identifiers against the 
161      * service epr addresses (service scope) or wsa:Action values (operation 
162      * scope).
163      */
164     public static final String KEY_CONTEXT_MAP = "contextMap";
165     
166     private ConversationConstants() {
167         // Complete
168     }
169     
170     public interface DerivationAlgorithm {
171         String P_SHA_1 = 
172             "http://schemas.xmlsoap.org/ws/2005/02/sc/dk/p_sha1";
173         
174         String P_SHA_1_2005_12 = 
175             "http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/dk/p_sha1";
176     }
177     
178     public static String getWSCNs(int version) throws ConversationException {
179         if (VERSION_05_02 == version) {
180             return WSC_NS_05_02;
181         } else if (VERSION_05_12 == version) {
182             return WSC_NS_05_12;
183         } else {
184             throw new ConversationException("unsupportedSecConvVersion");
185         }
186     }
187     
188     public static int getWSTVersion(String ns) throws ConversationException {
189         if (WSC_NS_05_02.equals(ns)) {
190             return VERSION_05_02;
191         } else if (WSC_NS_05_12.equals(ns)) {
192             return VERSION_05_12;
193         } else {
194             throw new ConversationException("unsupportedSecConvVersion");
195         }
196     }
197 }