1 /*
2 * Copyright 2005-2007 The Kuali Foundation
3 *
4 *
5 * Licensed under the Educational Community License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.opensource.org/licenses/ecl2.php
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.kuali.rice.ksb.config.xfire;
18
19 import java.util.Properties;
20
21 import org.apache.log4j.Logger;
22 import org.apache.ws.security.components.crypto.Crypto;
23 import org.apache.ws.security.components.crypto.Merlin;
24 import org.apache.ws.security.handler.RequestData;
25 import org.apache.ws.security.handler.WSHandlerConstants;
26 /*
27 import org.codehaus.xfire.MessageContext;
28 import org.codehaus.xfire.security.wss4j.WSS4JOutHandler;
29 */
30 import org.kuali.rice.core.config.ConfigContext;
31 import org.kuali.rice.core.exception.RiceRuntimeException;
32 import org.kuali.rice.core.util.ClassLoaderUtils;
33 import org.kuali.rice.ksb.config.wss4j.CryptoPasswordCallbackHandler;
34 import org.kuali.rice.ksb.messaging.ServiceInfo;
35
36
37 /**
38 *
39 * @author Kuali Rice Team (rice.collab@kuali.org)
40 */
41
42 //TODO: Replace this class with a cxf wss4j out interceptor
43 public class XFireWSS4JOutHandler {}
44
45 /*
46 public class XFireWSS4JOutHandler extends WSS4JOutHandler {
47
48 private static final Logger LOG = Logger.getLogger(XFireWSS4JOutHandler.class);
49
50 private ServiceInfo serviceInfo;
51
52 public XFireWSS4JOutHandler(ServiceInfo serviceInfo) {
53 this.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
54 this.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, CryptoPasswordCallbackHandler.class.getName());
55 this.setProperty(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial");
56 this.setProperty(WSHandlerConstants.USER, ConfigContext.getCurrentContextConfig().getKeystoreAlias());
57 this.serviceInfo = serviceInfo;
58 }
59
60 @Override
61 public Crypto loadSignatureCrypto(RequestData reqData) {
62 try {
63 return new Merlin(getMerlinProperties(), ClassLoaderUtils.getDefaultClassLoader());
64 } catch (Exception e) {
65 throw new RiceRuntimeException(e);
66 }
67 }
68
69 @Override
70 public Crypto loadDecryptionCrypto(RequestData reqData) {
71 return loadSignatureCrypto(reqData);
72 }
73
74 protected Properties getMerlinProperties() {
75 Properties props = new Properties();
76 props.put("org.apache.ws.security.crypto.merlin.keystore.type", "jks");
77 props.put("org.apache.ws.security.crypto.merlin.keystore.password", ConfigContext.getCurrentContextConfig().getKeystorePassword());
78 props.put("org.apache.ws.security.crypto.merlin.alias.password", ConfigContext.getCurrentContextConfig().getKeystorePassword());
79 props.put("org.apache.ws.security.crypto.merlin.keystore.alias", ConfigContext.getCurrentContextConfig().getKeystoreAlias());
80 props.put("org.apache.ws.security.crypto.merlin.file", ConfigContext.getCurrentContextConfig().getKeystoreFile());
81
82 if (LOG.isDebugEnabled()) {
83 LOG.debug("Using keystore location " + ConfigContext.getCurrentContextConfig().getKeystoreFile());
84 }
85
86 return props;
87 }
88
89 @Override
90 public void invoke(MessageContext context) throws Exception {
91 if (getServiceInfo().getServiceDefinition().getBusSecurity()) {
92 super.invoke(context);
93 }
94 }
95
96 public ServiceInfo getServiceInfo() {
97 return serviceInfo;
98 }
99
100 public void setServiceInfo(ServiceInfo serviceInfo) {
101 this.serviceInfo = serviceInfo;
102 }
103
104 }
105 */