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 * @author Ryan Goulding (ryandgoulding@gmail.com)
21 public class ODLPrincipalImpl implements ODLPrincipal {
23 private final String username;
24 private final String domain;
25 private final String userId;
26 private final Set<String> roles;
28 private ODLPrincipalImpl(final String username, final String domain, final String userId, final Set<String> roles) {
29 this.username = username;
36 * A static factory method to create <code>ODLPrincipal</code> instances.
38 * @param auth Contains identifying information for the particular request.
39 * @return A Principal for the given session; essentially a DTO.
41 public static ODLPrincipal createODLPrincipal(Authentication auth) {
42 return createODLPrincipal(auth.user(), auth.domain(), auth.userId(), auth.roles());
46 * A static factory method to create <code>ODLPrincipal</code> instances.
48 * @param username The authenticated user
49 * @param domain The domain <code>username</code> belongs to.
50 * @param userId The unique key for <code>username</code>
51 * @param roles The roles associated with <code>username</code>@<code>domain</code>
52 * @return A Principal for the given session; essentially a DTO.
54 public static ODLPrincipal createODLPrincipal(String username, String domain,
55 String userId, Set<String> roles) {
57 return new ODLPrincipalImpl(username, domain, userId, roles);
61 public String getUsername() {
66 public String getDomain() {
71 public String getUserId() {
76 public Set<String> getRoles() {