01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.bus.security.jms;
17:
18: import javax.jms.JMSException;
19: import javax.jms.Message;
20:
21: import org.kuali.bus.security.credentials.SecurityUtils;
22: import org.kuali.rice.security.credentials.Credentials;
23: import org.kuali.rice.security.credentials.CredentialsSource;
24: import org.logicblaze.lingo.jms.JmsProxyFactoryBean;
25: import org.springframework.util.Assert;
26:
27: import edu.iu.uis.eden.messaging.ServiceInfo;
28:
29: /**
30: * Extension to JmsProxyFactoryBean that takes Authentication information from
31: * the CredentialsSource and passes it along with the JMS message via the object
32: * property <code>CONST_KUALI_JMS_AUTHENTICATION</code>.
33: *
34: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
35: * @version $Revision: 1.2.16.1.6.1 $ $Date: 2007/10/17 20:32:06 $
36: * @since 0.9
37: */
38: public class AuthenticationJmsProxyFactoryBean extends
39: JmsProxyFactoryBean {
40:
41: /**
42: * Public constant defining the location of the Kuali authentication
43: * information within the JMS message.
44: */
45: public static final String CONST_KUALI_JMS_AUTHENTICATION = "kuali.authentication";
46:
47: /** Source of the credentials to send with the JMS message. */
48: private final CredentialsSource credentialsSource;
49:
50: /** Information about the service the message is being sent to. */
51: private final ServiceInfo serviceInfo;
52:
53: public AuthenticationJmsProxyFactoryBean(
54: final CredentialsSource credentialsSource,
55: final ServiceInfo serviceInfo) {
56: Assert.notNull(credentialsSource,
57: "credentialsSource cannot be null.");
58: Assert.notNull(serviceInfo, "serviceInfo cannot be null.");
59: this .credentialsSource = credentialsSource;
60: this .serviceInfo = serviceInfo;
61: }
62:
63: /**
64: * Utilizing the CredentialsSource, will add the Authentication information
65: * as the property "authentication".
66: */
67: protected void populateHeaders(final Message requestMessage)
68: throws JMSException {
69: super .populateHeaders(requestMessage);
70: final Credentials credentials = this.credentialsSource
71: .getCredentials(this.serviceInfo.getEndpointUrl());
72:
73: requestMessage
74: .setObjectProperty(
75: CONST_KUALI_JMS_AUTHENTICATION,
76: SecurityUtils
77: .convertCredentialsToSecurityContext(credentials));
78: }
79: }
|