Example: Extending AbstractAuthenticationProvider

The listing below provides an illustration of Extending the AbstractAuthenticationProvider. Please refer to the API JavaDoc for more information about these classes.

Listing 1. Extending the AbstractAuthenticationProvider Class

public class MyAuthentication extends inetsoft.sree.security.AbstractAuthenticationProvider {

 

   public boolean authenticate(String user, Object credential){

      //validate user credentials

      //credential is object of type

      //inetsoft.sree.security.DefaultTicket

   }

   public String[] getUsers() {

      // return a list of all user logins

   }

 

   public String[] getUsers(String group) {

      // return a list of usernames in the given group

   }

 

   public String[] getIndividualUsers() {

      // return a list of usernames not belonging to a group

   }

 

   public User getUser(String name) {

      // return a inetsoft.sree.security.User object

   }

 

   public String[] getRoles() {

      // return a list of all Roles

   }

 

   public String[] getRoles(String user) {

      // return a list of all Roles for a given user

   }

 

   public Role getRole(String name) {

      // return a inetsoft.sree.security.Role object

   }

 

   public String[] getGroups() {

      // return a list of all Groups

   }

 

   public Group getGroup(String name) {

      // return a inetsoft.sree.security.Group object

   }

 

   public void teardown() {

      //teardown the security provider

   }

 

}

Note: Do not override the 'findIdentity()' method of the 'AbstractAuthenticationProvider' as it is already complete.

It is advisable to implement internal caching within your security provider (especially if it is DB-based), because many methods such as 'getUsers()', 'getUser()', etc., are invoked repeatedly. Retrieval of this information from the DB for each invocation could cause performance/resource deterioration. However, if your security provider extends AbstractSecurityProvider, simply set 'security.cache=true' in the sree.properties file to enable caching.

<< Required Settings for Composite Security © 1996-2013 InetSoft Technology Corporation (v11.4) Example: Extending AbstractAuthorizationProvider >>