Jump to content
We've recently updated our Privacy Statement, available here ×

Users and Roles API java


ani786

Recommended Posts

I need to set attributes on the user

 
API has  user.setAttributes(List list) //import com.jaspersoft.jasperserver.api.metadata.user.domain.User;
 
I just need to know how do I add the Name=Value in the list  is it by = separator or???? please do let me know  since i am not able to find any api or help regarding the List inputs
 
Also I need the code for 
Profile Attributes:
 
i ddid the following but i get an excpetion shown below
 profileAttributeService.putProfileAttribute(null, paPersonId); /* here exception as org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext
   /*at org.springframework.security.access.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:339)**/
         profileAttributeService.applyProfileAttributes(); 
 
to overcome the exception can you give me some piece of code or hack :)
          
          
 
Regards
Ani
 
 
the below method is working fine ..........
 
    @Autowired
    private UserAuthorityService userAuthorityService;
 
   private User setUser(Map<String, String> externalUserProfileAttribsMap, String tenantId) 
    {
 
           
   if(logger.isDebugEnabled())
          logger.debug("============Entered setUser  userAuthorityService class ==================="  + userAuthorityService    +  "tenantId"  +tenantId);
     User user =userAuthorityService.newUser(null);
     user.setUsername(externalUserProfileAttribsMap.get("givennames")+"_"+externalUserProfileAttribsMap.get("surname"));                
          user.setTenantId("intech_test");
          user.setPassword("Password1!");  
          user.setFullName(externalUserProfileAttribsMap.get("givennames")+ externalUserProfileAttribsMap.get("surname")); // We don't know the real name
          user.setEnabled(true);   
          user.setExternallyDefined(false);  
         
          user.setEmailAddress(externalUserProfileAttribsMap.get("emailaddress"));
        
              
          Role role = new RoleImpl();
          role.setRoleName("ROLE_USER");         
          user.addRole(role);
         userAuthorityService.putUser(null, user);   
          
        
    }
 
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...