001/* 002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $ 020 */ 021 022package org.nuxeo.ecm.platform.api.login; 023 024import static org.apache.commons.lang3.StringUtils.isBlank; 025 026import java.io.Serializable; 027 028import org.nuxeo.ecm.core.api.NuxeoException; 029 030/** 031 * Encapsulates some information about a user and how it must be authenticated. 032 * 033 * @author <a href="mailto:td@nuxeo.com">Thierry Delprat</a> 034 */ 035public class UserIdentificationInfo implements Serializable { 036 037 private static final long serialVersionUID = 6894397878763275157L; 038 039 protected String userName; 040 041 protected String password; 042 043 /** @since 11.1 */ 044 protected boolean credentialsChecked; 045 046 protected String token; 047 048 protected String authPluginName; 049 050 public UserIdentificationInfo(String userName) { 051 if (isBlank(userName)) { 052 throw new NuxeoException("username must not be blank"); 053 } 054 this.userName = userName; 055 this.credentialsChecked = true; 056 } 057 058 public UserIdentificationInfo(String userName, String password) { 059 if (isBlank(userName)) { 060 throw new NuxeoException("username must not be blank"); 061 } 062 this.userName = userName; 063 this.password = password; 064 } 065 066 public UserIdentificationInfo(UserIdentificationInfo savedIdent) { 067 this(savedIdent.userName, savedIdent.password); 068 credentialsChecked = savedIdent.credentialsChecked; 069 token = savedIdent.token; 070 authPluginName = savedIdent.authPluginName; 071 } 072 073 /** 074 * Returns the name of the Authentication Plugin used to get user identity (FORM,BASIC,CAS2 ...). 075 */ 076 public String getAuthPluginName() { 077 return authPluginName; 078 } 079 080 public void setAuthPluginName(String authPluginName) { 081 this.authPluginName = authPluginName; 082 } 083 084 public String getPassword() { 085 return password; 086 } 087 088 public void setPassword(String password) { 089 this.password = password; 090 } 091 092 public String getUserName() { 093 return userName; 094 } 095 096 public void setUserName(String userName) { 097 if (isBlank(userName)) { 098 throw new NuxeoException("username must not be blank"); 099 } 100 this.userName = userName; 101 } 102 103 /** @since 11.1 */ 104 public boolean credentialsChecked() { 105 return credentialsChecked; 106 } 107 108 /** @since 11.1 */ 109 public void setCredentialsChecked(boolean credentialsChecked) { 110 this.credentialsChecked = credentialsChecked; 111 } 112 113 public String getToken() { 114 return token; 115 } 116 117 public void setToken(String token) { 118 this.token = token; 119 } 120 121}