View Javadoc

1   /*
2    * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
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  
17  package edu.internet2.middleware.shibboleth.common.config.relyingparty;
18  
19  import java.util.List;
20  import java.util.Map;
21  
22  import org.opensaml.xml.security.credential.Credential;
23  import org.springframework.beans.factory.config.AbstractFactoryBean;
24  
25  import edu.internet2.middleware.shibboleth.common.relyingparty.ProfileConfiguration;
26  import edu.internet2.middleware.shibboleth.common.relyingparty.RelyingPartyConfiguration;
27  
28  /**
29   * Relying party configuration factory bean.
30   */
31  public class RelyingPartyFactoryBean extends AbstractFactoryBean {
32      
33      /** ID of the relying party. */
34      private String relyingPartyId;
35  
36      /** ID of the provider to use for this relying party. */
37      private String providerId;
38      
39      /** Authentication method to use if none is specified within a request. */
40      private String defaultAuthenticationMethod;
41  
42      /** The default signing credential for this relying party. */
43      private Credential defaultSigningCredential;
44  
45      /** Registered profile configurations. */
46      private List<ProfileConfiguration> profileConfigurations;
47  
48      /** {@inheritDoc} */
49      public Class getObjectType() {
50          return RelyingPartyConfiguration.class;
51      }
52      
53      /**
54       * Gets the ID of the relying party.
55       * 
56       * @return ID of the provider to use for this relying party
57       */
58      public String getRelyingPartyId() {
59          return relyingPartyId;
60      }
61  
62      /**
63       * Sets the ID of the relying party.
64       * 
65       * @param id ID of the relying party
66       */
67      public void setRelyingPartyId(String id) {
68          relyingPartyId = id;
69      }
70  
71      /**
72       * Gets the ID of the provider to use for this relying party.
73       * 
74       * @return ID of the provider to use for this relying party
75       */
76      public String getProviderId() {
77          return providerId;
78      }
79  
80      /**
81       * Sets the ID of the provider to use for this relying party.
82       * 
83       * @param id ID of the provider to use for this relying party
84       */
85      public void setProviderId(String id) {
86          providerId = id;
87      }
88      
89      /**
90       * Gets the authentication method to use if one is not specified within a request.
91       * 
92       * @return authentication method to use if one is not specified within a request
93       */
94      public String getDefaultAuthenticationMethod() {
95          return defaultAuthenticationMethod;
96      }
97  
98      /**
99       * Sets the authentication method to use if one is not specified within a request.
100      * 
101      * @param method authentication method to use if one is not specified within a request
102      */
103     public void setDefaultAuthenticationMethod(String method) {
104         defaultAuthenticationMethod = method;
105     }
106 
107     /**
108      * Gets the default signing credential for this relying party.
109      * 
110      * @return default signing credential for this relying party
111      */
112     public Credential getDefaultSigningCredential() {
113         return defaultSigningCredential;
114     }
115 
116     /**
117      * Sets the default signing credential for this relying party.
118      * 
119      * @param credential default signing credential for this relying party
120      */
121     public void setDefaultSigningCredential(Credential credential) {
122         defaultSigningCredential = credential;
123     }
124 
125     /**
126      * Gets the registered profile configurations.
127      * 
128      * @return registered profile configurations
129      */
130     public List<ProfileConfiguration> getProfileConfigurations() {
131         return profileConfigurations;
132     }
133 
134     /**
135      * Sets the registered profile configurations.
136      * 
137      * @param configurations registered profile configurations
138      */
139     public void setProfileConfigurations(List<ProfileConfiguration> configurations) {
140         profileConfigurations = configurations;
141     }
142 
143     /** {@inheritDoc} */
144     protected Object createInstance() throws Exception {
145         RelyingPartyConfiguration configuration = new RelyingPartyConfiguration(relyingPartyId, providerId);
146         configuration.setDefaultAuthenticationMethod(defaultAuthenticationMethod);
147         configuration.setDefaultSigningCredential(defaultSigningCredential);
148 
149         if (profileConfigurations != null) {
150             Map<String, ProfileConfiguration> registeredProfileConfigs = configuration.getProfileConfigurations();
151             for (ProfileConfiguration profileConfig : profileConfigurations) {
152                 registeredProfileConfigs.put(profileConfig.getProfileId(), profileConfig);
153             }
154         }
155 
156         return configuration;
157     }
158 }