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