Cleaned up imports.
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / metadata / EntityDescriptor.java
1 /*
2  * EntityDescriptor.java
3  * 
4  * Simplify the transition to SAML 2 by allowing the obsolete
5  * "Provider" interface to be called by its new name "EntityDescriptor".
6  * Can be used to add or rename fields while writing code that 
7  * implements the new interface while continuing to support the old.
8  */
9 package edu.internet2.middleware.shibboleth.metadata;
10
11 /**
12  * @author Howard Gilbert
13  */
14 public abstract class EntityDescriptor implements Provider {
15     
16     /**
17      * Scan the array of Roles, return instance of a particular type
18      * @param type  Sub-Class of ProviderRole
19      * @return      instance of the type
20      */
21     public ProviderRole getRoleByType(Class type) {
22         
23         ProviderRole[] roles = this.getRoles();
24         for (int i=0;i<roles.length;i++) {
25             ProviderRole role = roles[i];
26             if (type.isInstance(role))
27                 return role;
28         }
29          return null;
30     }
31     
32     public 
33         AttributeAuthorityRole 
34     getAttributeAuthorityRole(){
35         AttributeAuthorityRole aa = (AttributeAuthorityRole) getRoleByType(AttributeAuthorityRole.class);
36         return aa;
37     }
38         
39     public 
40         IDPProviderRole 
41     getHandleServer() {
42         IDPProviderRole hs = (IDPProviderRole) getRoleByType(IDPProviderRole.class);
43         return hs;
44     }
45
46     
47
48 }