| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
| SidRetrievalStrategyImpl |
|
| 2.0;2 |
| 1 | /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited |
|
| 2 | * |
|
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 4 | * you may not use this file except in compliance with the License. |
|
| 5 | * You may obtain a copy of the License at |
|
| 6 | * |
|
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 | * |
|
| 9 | * Unless required by applicable law or agreed to in writing, software |
|
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 12 | * See the License for the specific language governing permissions and |
|
| 13 | * limitations under the License. |
|
| 14 | */ |
|
| 15 | ||
| 16 | package org.acegisecurity.acls.sid; |
|
| 17 | ||
| 18 | import org.acegisecurity.Authentication; |
|
| 19 | import org.acegisecurity.GrantedAuthority; |
|
| 20 | ||
| 21 | import java.util.List; |
|
| 22 | import java.util.Vector; |
|
| 23 | ||
| 24 | ||
| 25 | /** |
|
| 26 | * Basic implementation of {@link SidRetrievalStrategy} that creates a {@link Sid} for the principal, as well as |
|
| 27 | * every granted authority the principal holds.<p>The returned array will always contain the {@link PrincipalSid} |
|
| 28 | * before any {@link GrantedAuthoritySid} elements.</p> |
|
| 29 | * |
|
| 30 | * @author Ben Alex |
|
| 31 | * @version $Id: SidRetrievalStrategyImpl.java 1754 2006-11-17 02:01:21Z benalex $ |
|
| 32 | */ |
|
| 33 | 1 | public class SidRetrievalStrategyImpl implements SidRetrievalStrategy { |
| 34 | //~ Methods ======================================================================================================== |
|
| 35 | ||
| 36 | public Sid[] getSids(Authentication authentication) { |
|
| 37 | 0 | List list = new Vector(); |
| 38 | 0 | list.add(new PrincipalSid(authentication)); |
| 39 | ||
| 40 | 0 | GrantedAuthority[] authorities = authentication.getAuthorities(); |
| 41 | ||
| 42 | 0 | for (int i = 0; i < authorities.length; i++) { |
| 43 | 0 | list.add(new GrantedAuthoritySid(authorities[i])); |
| 44 | } |
|
| 45 | ||
| 46 | 0 | return (Sid[]) list.toArray(new Sid[] {}); |
| 47 | } |
|
| 48 | } |