09-15-2016 06:07 AM
public class MySecurityOverride implements AlfrescoApiSecurityOverride {
@Bean
public AuthenticationProvider authenticationProvider() {
return new MyAuthenticationProvider();
}
public void configure(HttpSecurity http) throws Exception {
http
.authenticationProvider(authenticationProvider())
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.csrf().disable()
.authorizeRequests()
.anyRequest().authenticated()
.and()
.httpBasic();
}
}
public class MyAuthenticationProvider implements AuthenticationProvider{
@Autowired
private IdentityService identityService;
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
String name = authentication.getName();
String password = authentication.getCredentials().toString();
boolean authenticated = identityService.checkPassword(name, password);
List<String> userkeys = identityService.getUserInfoKeys("admin@app.activiti.com");
if (authenticated) {
List<Group> groups = identityService.createGroupQuery().groupMember(name).list();
Collection<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
for (Group group : groups) {
grantedAuthorities.add(new SimpleGrantedAuthority(group.getId()));
}
identityService.setAuthenticatedUserId(name);
//GrantedAuthorityImpl grantedAdmin = new GrantedAuthorityImpl("ROLE_ADMIN");
//Collection<GrantedAuthority> grantedtest = new ArrayList();
//grantedtest.add(grantedAdmin);
return new UsernamePasswordAuthenticationToken(name, password, grantedtest);
} else {
throw new BadCredentialsException("Authentication failed for this username and password");
}
}
public boolean supports(Class<?> authentication) {
Boolean returnval = authentication.equals(UsernamePasswordAuthenticationToken.class);
return returnval;
}
}
org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/activiti-app/app/logout] in DispatcherServlet with name 'appDispatcher'
09-19-2016 05:31 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.