View Javadoc

1   /*
2    * Licensed to the University Corporation for Advanced Internet Development, 
3    * Inc. (UCAID) under one or more contributor license agreements.  See the 
4    * NOTICE file distributed with this work for additional information regarding
5    * copyright ownership. The UCAID licenses this file to You under the Apache 
6    * License, Version 2.0 (the "License"); you may not use this file except in 
7    * compliance with the License.  You may obtain a copy of the License at
8    *
9    *    http://www.apache.org/licenses/LICENSE-2.0
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  
18  package edu.internet2.middleware.shibboleth.common.config.relyingparty.saml;
19  
20  import java.util.List;
21  
22  import edu.internet2.middleware.shibboleth.common.attribute.provider.SAML2AttributeAuthority;
23  import edu.internet2.middleware.shibboleth.common.relyingparty.provider.CryptoOperationRequirementLevel;
24  import edu.internet2.middleware.shibboleth.common.relyingparty.provider.saml2.AbstractSAML2ProfileConfiguration;
25  
26  /**
27   * Base Spring factory bean for SAML 2 profile configurations.
28   */
29  public abstract class AbstractSAML2ProfileConfigurationFactoryBean extends AbstractSAMLProfileConfigurationFactoryBean {
30  
31      /** Attribute authority for the profile configuration. */
32      private SAML2AttributeAuthority attributeAuthority;
33      
34      /** Whether to encrypt NameIDs. */
35      private CryptoOperationRequirementLevel encryptNameIds;
36  
37      /** Whether to encryptAssertions. */
38      private CryptoOperationRequirementLevel encryptAssertions;
39  
40      /** Maximum number of times an assertion may be proxied. */
41      private int assertionProxyCount;
42      
43      /** Audiences for proxied assertions. */
44      private List<String> proxyAudiences;
45  
46      /**
47       * Gets the attribute authority for the profile configuration.
48       * 
49       * @return attribute authority for the profile configuration
50       */
51      public SAML2AttributeAuthority getAttributeAuthority(){
52          return attributeAuthority;
53      }
54      
55      /**
56       * Sets the attribute authority for the profile configuration.
57       * 
58       * @param authority attribute authority for the profile configuration
59       */
60      public void setAttributeAuthority(SAML2AttributeAuthority authority){
61          attributeAuthority = authority;
62      }
63      
64      /**
65       * Gets the maximum number of times an assertion may be proxied.
66       * 
67       * @return maximum number of times an assertion may be proxied
68       */
69      public int getAssertionProxyCount() {
70          return assertionProxyCount;
71      }
72  
73      /**
74       * Sets the maximum number of times an assertion may be proxied.
75       * 
76       * @param count maximum number of times an assertion may be proxied
77       */
78      public void setAssertionProxyCount(int count) {
79          assertionProxyCount = count;
80      }
81  
82      /**
83       * Gets whether to encryption assertions.
84       * 
85       * @return whether to encryption assertions
86       */
87      public CryptoOperationRequirementLevel isEncryptAssertions() {
88          return encryptAssertions;
89      }
90  
91      /**
92       * Sets whether to encryption assertions.
93       * 
94       * @param encrypt whether to encryption assertions
95       */
96      public void setEncryptAssertions(CryptoOperationRequirementLevel encrypt) {
97          encryptAssertions = encrypt;
98      }
99  
100     /**
101      * Gets whether to encrypt NameIDs.
102      * 
103      * @return whether to encrypt NameIDs
104      */
105     public CryptoOperationRequirementLevel isEncryptNameIds() {
106         return encryptNameIds;
107     }
108 
109     /**
110      * Sets whether to encrypt NameIDs.
111      * 
112      * @param encrypt whether to encrypt NameIDs
113      */
114     public void setEncryptNameIds(CryptoOperationRequirementLevel encrypt) {
115         encryptNameIds = encrypt;
116     }
117     
118     /**
119      * Gets the audiences for proxied assertions.
120      * 
121      * @return audiences for proxied assertions
122      */
123     public List<String> getProxyAudiences(){
124         return proxyAudiences;
125     }
126     
127     /**
128      * Sets the audiences for proxied assertions.
129      * 
130      * @param audiences audiences for proxied assertions
131      */
132     public void setProxyAudiences(List<String> audiences){
133         proxyAudiences = audiences;
134     }
135     
136     /**
137      * Populates the given profile configuration with standard information.
138      * 
139      * @param configuration configuration to populate
140      */
141     protected void populateBean(AbstractSAML2ProfileConfiguration configuration){
142         super.populateBean(configuration);
143         
144         configuration.setAttributeAuthority(getAttributeAuthority());
145         configuration.setEncryptAssertion(isEncryptAssertions());
146         configuration.setEncryptNameID(isEncryptNameIds());
147         configuration.setProxyCount(getAssertionProxyCount());
148         
149         if(getProxyAudiences() != null){
150             configuration.getProxyAudiences().addAll(getProxyAudiences());
151         }
152     }
153 }