001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.cxf.configuration.jsse;
019:
020: import java.security.SecureRandom;
021: import java.util.ArrayList;
022: import java.util.List;
023:
024: import javax.net.ssl.KeyManager;
025: import javax.net.ssl.TrustManager;
026:
027: import org.apache.cxf.configuration.security.FiltersType;
028:
029: /**
030: * This class is the base class for TLS parameters that are common
031: * to both client and server sides.
032: */
033: public class TLSParameterBase {
034: private KeyManager[] keyManagers;
035: private TrustManager[] trustManagers;
036: private String provider;
037: private List<String> ciphersuites = new ArrayList<String>();
038: private FiltersType cipherSuiteFilters;
039: private SecureRandom secureRandom;
040: private String protocol;
041:
042: /**
043: * This parameter configures the JSSE provider. If not set, it
044: * uses system default.
045: */
046: public final void setJsseProvider(String prov) {
047: provider = prov;
048: }
049:
050: /**
051: * This parameter configures to use the following KeyManagers.
052: * This parameter may be set to null for system default behavior.
053: */
054: public final void setKeyManagers(KeyManager[] keyMgrs) {
055: keyManagers = keyMgrs;
056: }
057:
058: /**
059: * This parameter configures to use the following TrustManagers.
060: * This parameter may be set to null for system default behavior.
061: */
062: public final void setTrustManagers(TrustManager[] trustMgrs) {
063: trustManagers = trustMgrs;
064: }
065:
066: /**
067: * This parameter sets the cipher suites list to use. If left unset
068: * it uses system defaults.
069: */
070: public final void setCipherSuites(List<String> cs) {
071: ciphersuites = cs;
072: }
073:
074: /**
075: * This parameter sets the filter to include and/or exclude the
076: * cipher suites to use from the set list or system defaults.
077: */
078: public final void setCipherSuitesFilter(FiltersType filters) {
079: cipherSuiteFilters = filters;
080: }
081:
082: /**
083: * This sets the protocol to use. The system default is usually
084: * "TLS".
085: */
086: public final void setSecureSocketProtocol(String proto) {
087: protocol = proto;
088: }
089:
090: /**
091: * This sets the secure random provider and alogorithm. If left unset or set
092: * to null, it uses the system default.
093: */
094: public final void setSecureRandom(SecureRandom random) {
095: secureRandom = random;
096: }
097:
098: /**
099: * This sets the secure random alogorithm. If left unset or set
100: * to null, it uses the system default.
101: */
102: public SecureRandom getSecureRandom() {
103: return secureRandom;
104: }
105:
106: /**
107: * This sets the protocol to use. The system default is usually
108: * "TLS".
109: */
110: public String getSecureSocketProtocol() {
111: return protocol;
112: }
113:
114: /**
115: * This parameter configures the JSSE provider. If not set, it
116: * uses system default.
117: */
118: public String getJsseProvider() {
119: return provider;
120: }
121:
122: /**
123: * This parameter configures to use the following KeyManagers.
124: * This parameter may be set to null for system default behavior.
125: */
126: public KeyManager[] getKeyManagers() {
127: return keyManagers;
128: }
129:
130: /**
131: * This parameter configures to use the following TrustManagers.
132: * This parameter may be set to null for system default behavior.
133: */
134: public TrustManager[] getTrustManagers() {
135: return trustManagers;
136: }
137:
138: /**
139: * This parameter sets the cipher suites list to use. If left unset
140: * it uses system defaults.
141: */
142: public List<String> getCipherSuites() {
143: if (ciphersuites == null) {
144: ciphersuites = new ArrayList<String>();
145: }
146: return ciphersuites;
147: }
148:
149: /**
150: * This parameter sets the filter to include and/or exclude the
151: * cipher suites to use from the set list or system defaults.
152: */
153: public FiltersType getCipherSuitesFilter() {
154: return cipherSuiteFilters;
155: }
156: }
|