package org.argeo.security.core;
-import java.security.AccessController;
import java.util.ArrayList;
import java.util.List;
-import javax.security.auth.Subject;
-
import org.argeo.security.OsAuthenticationToken;
import org.springframework.security.Authentication;
import org.springframework.security.AuthenticationException;
import org.springframework.security.GrantedAuthority;
import org.springframework.security.GrantedAuthorityImpl;
import org.springframework.security.providers.AuthenticationProvider;
-import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
/** Validates an OS authentication. */
public class OsAuthenticationProvider implements AuthenticationProvider {
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
- final OsAuthenticationToken oat;
- // if (authentication instanceof UsernamePasswordAuthenticationToken) {
- // Subject subject = Subject.getSubject(AccessController.getContext());
- // if (subject == null)
- // return null;
- // oat = new OsAuthenticationToken();
- // } else
- if (authentication instanceof OsAuthenticationToken) {
- oat = (OsAuthenticationToken) authentication;
- } else {
+ if (!(authentication instanceof OsAuthenticationToken))
return null;
- }
-
- // not OS authenticated
-// if (oat.getUser() == null)
-// return null;
List<GrantedAuthority> auths = new ArrayList<GrantedAuthority>();
auths.add(new GrantedAuthorityImpl(osUserRole));
this.osUserRole = osUserRole;
}
+ public void setUserRole(String userRole) {
+ this.userRole = userRole;
+ }
+
public void setAdminRole(String adminRole) {
this.adminRole = adminRole;
}
private Credentials adminCredentials;
public void afterPropertiesSet() throws Exception {
+ if (repository != null) {
+ // we are just wrapping another repository
+ importNodeTypeDefinitions(repository);
+ return;
+ }
+
// remote repository
if (uri != null && !uri.trim().equals("")) {
Map<String, String> params = new HashMap<String, String>();
protected void importNodeTypeDefinitions(final Repository repository) {
final Credentials credentialsToUse;
if (systemExecutor == null) {
- if (adminCredentials == null)
- throw new ArgeoException(
- "No system executor or admin credentials found");
+ if (adminCredentials == null) {
+ log.error("No system executor or admin credentials found,"
+ + " cannot import node types");
+ return;
+ }
credentialsToUse = adminCredentials;
} else {
credentialsToUse = null;
this.adminCredentials = adminCredentials;
}
+ public void setRepository(Repository repository) {
+ this.repository = repository;
+ }
+
}