]> WPIA git - gigi.git/blob - lib/jetty/org/eclipse/jetty/security/SpnegoUserPrincipal.java
Merge "Update notes about password security"
[gigi.git] / lib / jetty / org / eclipse / jetty / security / SpnegoUserPrincipal.java
1 //
2 //  ========================================================================
3 //  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4 //  ------------------------------------------------------------------------
5 //  All rights reserved. This program and the accompanying materials
6 //  are made available under the terms of the Eclipse Public License v1.0
7 //  and Apache License v2.0 which accompanies this distribution.
8 //
9 //      The Eclipse Public License is available at
10 //      http://www.eclipse.org/legal/epl-v10.html
11 //
12 //      The Apache License v2.0 is available at
13 //      http://www.opensource.org/licenses/apache2.0.php
14 //
15 //  You may elect to redistribute this code under either of these licenses.
16 //  ========================================================================
17 //
18
19 package org.eclipse.jetty.security;
20
21 import java.security.Principal;
22
23 import org.eclipse.jetty.util.B64Code;
24
25 public class SpnegoUserPrincipal implements Principal
26 {
27     private final String _name;
28     private byte[] _token;
29     private String _encodedToken;
30
31     public SpnegoUserPrincipal( String name, String encodedToken )
32     {
33         _name = name;
34         _encodedToken = encodedToken;
35     }
36
37     public SpnegoUserPrincipal( String name, byte[] token )
38     {
39         _name = name;
40         _token = token;
41     }
42
43     public String getName()
44     {
45         return _name;
46     }
47
48     public byte[] getToken()
49     {
50         if ( _token == null )
51         {
52             _token = B64Code.decode(_encodedToken);
53         }
54         return _token;
55     }
56
57     public String getEncodedToken()
58     {
59         if ( _encodedToken == null )
60         {
61             _encodedToken = new String(B64Code.encode(_token,true));
62         }
63         return _encodedToken;
64     }
65 }