X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=security%2Fruntime%2Forg.argeo.security.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fsecurity%2Fcore%2FOsAuthenticationProvider.java;h=0e29ecd59a75e6fbfe0f422acce415508da73f4b;hb=3a3d316af102ba410d1d9e6de349d0c8f7ac044f;hp=3360b1eeae2c2cf5b1fd7bfb908448cc2fc67fe2;hpb=484dcb1507e4e35cc282e50522ea7eac7e99a7f9;p=lgpl%2Fargeo-commons.git diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/OsAuthenticationProvider.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/OsAuthenticationProvider.java index 3360b1eea..0e29ecd59 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/OsAuthenticationProvider.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/OsAuthenticationProvider.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.argeo.security.core; import java.util.ArrayList; @@ -14,21 +29,22 @@ import org.springframework.security.providers.AuthenticationProvider; * Validates an OS authentication. The id is that it will always be * authenticated since we are always runnign within an OS, but the fact that the * {@link Authentication} works properly depends on the proper OS login module - * having been called as well. + * having been called as well. TODO make it more configurable (base roles, is + * admin) */ public class OsAuthenticationProvider implements AuthenticationProvider { - private String osUserRole = "ROLE_OS_USER"; - private String userRole = "ROLE_USER"; - private String adminRole = "ROLE_ADMIN"; + final static String osUserRole = "ROLE_OS_USER"; + final static String userRole = "ROLE_USER"; + final static String adminRole = "ROLE_ADMIN"; - private Boolean isAdmin = true; + final static Boolean isAdmin = true; public Authentication authenticate(Authentication authentication) throws AuthenticationException { return new OsAuthenticationToken(getBaseAuthorities()); } - protected GrantedAuthority[] getBaseAuthorities() { + public static GrantedAuthority[] getBaseAuthorities() { List auths = new ArrayList(); auths.add(new GrantedAuthorityImpl(osUserRole)); auths.add(new GrantedAuthorityImpl(userRole)); @@ -42,20 +58,4 @@ public class OsAuthenticationProvider implements AuthenticationProvider { return OsAuthenticationToken.class.isAssignableFrom(authentication); } - public void setOsUserRole(String osUserRole) { - this.osUserRole = osUserRole; - } - - public void setUserRole(String userRole) { - this.userRole = userRole; - } - - public void setAdminRole(String adminRole) { - this.adminRole = adminRole; - } - - public void setIsAdmin(Boolean isAdmin) { - this.isAdmin = isAdmin; - } - }