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.
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
19 package org.eclipse.jetty.security.authentication;
21 import java.security.Principal;
23 import javax.security.auth.Subject;
25 import org.eclipse.jetty.security.IdentityService;
28 * This is similar to the jaspi PasswordValidationCallback but includes user
29 * principal and group info as well.
31 * @version $Rev: 4793 $ $Date: 2009-03-19 00:00:01 +0100 (Thu, 19 Mar 2009) $
33 public class LoginCallbackImpl implements LoginCallback
36 private final Subject subject;
38 private final String userName;
40 private Object credential;
42 private boolean success;
44 private Principal userPrincipal;
46 private String[] roles = IdentityService.NO_ROLES;
48 //TODO could use Credential instance instead of Object if Basic/Form create a Password object
49 public LoginCallbackImpl (Subject subject, String userName, Object credential)
51 this.subject = subject;
52 this.userName = userName;
53 this.credential = credential;
56 public Subject getSubject()
61 public String getUserName()
66 public Object getCredential()
71 public boolean isSuccess()
76 public void setSuccess(boolean success)
78 this.success = success;
81 public Principal getUserPrincipal()
86 public void setUserPrincipal(Principal userPrincipal)
88 this.userPrincipal = userPrincipal;
91 public String[] getRoles()
96 public void setRoles(String[] groups)
101 public void clearPassword()
103 if (credential != null)