1// 2// ======================================================================== 3// Copyright (c) 1995-2014 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 19package org.eclipse.jetty.security.authentication; 20 21import java.security.Principal; 22 23import javax.security.auth.Subject; 24 25import org.eclipse.jetty.security.IdentityService; 26 27/** 28 * This is similar to the jaspi PasswordValidationCallback but includes user 29 * principal and group info as well. 30 * 31 * @version $Rev: 4793 $ $Date: 2009-03-19 00:00:01 +0100 (Thu, 19 Mar 2009) $ 32 */ 33public class LoginCallbackImpl implements LoginCallback 34{ 35 // initial data 36 private final Subject subject; 37 38 private final String userName; 39 40 private Object credential; 41 42 private boolean success; 43 44 private Principal userPrincipal; 45 46 private String[] roles = IdentityService.NO_ROLES; 47 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) 50 { 51 this.subject = subject; 52 this.userName = userName; 53 this.credential = credential; 54 } 55 56 public Subject getSubject() 57 { 58 return subject; 59 } 60 61 public String getUserName() 62 { 63 return userName; 64 } 65 66 public Object getCredential() 67 { 68 return credential; 69 } 70 71 public boolean isSuccess() 72 { 73 return success; 74 } 75 76 public void setSuccess(boolean success) 77 { 78 this.success = success; 79 } 80 81 public Principal getUserPrincipal() 82 { 83 return userPrincipal; 84 } 85 86 public void setUserPrincipal(Principal userPrincipal) 87 { 88 this.userPrincipal = userPrincipal; 89 } 90 91 public String[] getRoles() 92 { 93 return roles; 94 } 95 96 public void setRoles(String[] groups) 97 { 98 this.roles = groups; 99 } 100 101 public void clearPassword() 102 { 103 if (credential != null) 104 { 105 credential = null; 106 } 107 } 108 109} 110