2 * Copyright (c) 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.aaa.shiro.principal;
12 import org.opendaylight.aaa.api.Authentication;
13 import org.opendaylight.aaa.api.shiro.principal.ODLPrincipal;
16 * An ODL specific principal which stores some critical information about the user
17 * making the auth request.
19 public class ODLPrincipalImpl implements ODLPrincipal {
21 private final String username;
22 private final String domain;
23 private final String userId;
24 private final Set<String> roles;
26 private ODLPrincipalImpl(final String username, final String domain, final String userId, final Set<String> roles) {
27 this.username = username;
34 * A static factory method to create <code>ODLPrincipal</code> instances.
36 * @param auth Contains identifying information for the particular request.
37 * @return A Principal for the given session; essentially a DTO.
39 public static ODLPrincipal createODLPrincipal(Authentication auth) {
40 return createODLPrincipal(auth.user(), auth.domain(), auth.userId(), auth.roles());
44 * A static factory method to create <code>ODLPrincipal</code> instances.
46 * @param username The authenticated user
47 * @param domain The domain <code>username</code> belongs to.
48 * @param userId The unique key for <code>username</code>
49 * @param roles The roles associated with <code>username</code>@<code>domain</code>
50 * @return A Principal for the given session; essentially a DTO.
52 public static ODLPrincipal createODLPrincipal(String username, String domain,
53 String userId, Set<String> roles) {
55 return new ODLPrincipalImpl(username, domain, userId, roles);
59 * A static factory method to create <code>ODLPrincipal</code> instances w/o roles.
61 * @param username The authenticated user
62 * @param domain The domain <code>username</code> belongs to.
63 * @param userId The unique key for <code>username</code>
64 * @return A Principal for the given session; essentially a DTO.
66 public static ODLPrincipal createODLPrincipal(String username, String domain,
68 return ODLPrincipalImpl.createODLPrincipal(username, domain, userId, null);
72 public String getUsername() {
77 public String getDomain() {
82 public String getUserId() {
87 public Set<String> getRoles() {