001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.isis.extensions.secman.api.user; 020 021import java.util.SortedSet; 022 023import org.apache.isis.applib.services.HasUsername; 024import org.apache.isis.extensions.secman.api.IsisModuleExtSecmanApi; 025import org.apache.isis.extensions.secman.api.permission.ApplicationPermissionValueSet; 026import org.apache.isis.extensions.secman.api.role.ApplicationRole; 027import org.apache.isis.extensions.secman.api.tenancy.HasAtPath; 028 029 030public interface ApplicationUser extends HasUsername, HasAtPath { 031 032 // -- CONSTANTS 033 034 public static final int MAX_LENGTH_USERNAME = 30; 035 public static final int MAX_LENGTH_FAMILY_NAME = 50; 036 public static final int MAX_LENGTH_GIVEN_NAME = 50; 037 public static final int MAX_LENGTH_KNOWN_AS = 20; 038 public static final int MAX_LENGTH_EMAIL_ADDRESS = 50; 039 public static final int MAX_LENGTH_PHONE_NUMBER = 25; 040 041 // -- DOMAIN EVENTS 042 043 public static abstract class PropertyDomainEvent<T> extends IsisModuleExtSecmanApi.PropertyDomainEvent<ApplicationUser, T> {} 044 public static abstract class CollectionDomainEvent<T> extends IsisModuleExtSecmanApi.CollectionDomainEvent<ApplicationUser, T> {} 045 public static abstract class ActionDomainEvent extends IsisModuleExtSecmanApi.ActionDomainEvent<ApplicationUser> {} 046 047 public static class AddRoleDomainEvent extends ActionDomainEvent {} 048 public static class UpdateAtPathDomainEvent extends ActionDomainEvent {} 049 public static class UpdateUsernameDomainEvent extends ActionDomainEvent {} 050 public static class UpdateNameDomainEvent extends ActionDomainEvent {} 051 public static class UpdateEmailAddressDomainEvent extends ActionDomainEvent {} 052 public static class UpdatePhoneNumberDomainEvent extends ActionDomainEvent {} 053 public static class UpdateFaxNumberDomainEvent extends ActionDomainEvent {} 054 public static class UpdateAccountTypeDomainEvent extends ActionDomainEvent {} 055 public static class UnlockDomainEvent extends ActionDomainEvent {} 056 public static class LockDomainEvent extends ActionDomainEvent {} 057 public static class UpdatePasswordDomainEvent extends ActionDomainEvent {} 058 public static class ResetPasswordDomainEvent extends ActionDomainEvent {} 059 public static class RemoveRoleDomainEvent extends ActionDomainEvent {} 060 public static class DeleteDomainEvent extends ActionDomainEvent {} 061 public static class NewDelegateUserDomainEvent extends ActionDomainEvent {} 062 public static class NewLocalUserDomainEvent extends ActionDomainEvent {} 063 public static class UserDuplicateDomainEvent extends ActionDomainEvent {} 064 065 // -- MODEL 066 067 /** 068 * having a title() method (rather than using @Title annotation) is necessary as a workaround to be able to use 069 * wrapperFactory#unwrap(...) method, which is otherwise broken in Isis 1.6.0 070 */ 071 default String title() { 072 return getName(); 073 } 074 075 default String iconName() { 076 return getStatus().isEnabled() ? "enabled" : "disabled"; 077 } 078 079 String getName(); 080 081 String getEncryptedPassword(); 082 083 AccountType getAccountType(); 084 void setAccountType(AccountType accountType); 085 086 ApplicationPermissionValueSet getPermissionSet(); 087 088 SortedSet<? extends ApplicationRole> getRoles(); 089 090 ApplicationUserStatus getStatus(); 091 void setStatus(ApplicationUserStatus disabled); 092 093 void setAtPath(String atPath); 094 095 String getEmailAddress(); 096 void setEmailAddress(String emailAddress); 097 098 String getFaxNumber(); 099 void setFaxNumber(String faxNumber); 100 101 String getFamilyName(); 102 void setFamilyName(String familyName); 103 104 String getGivenName(); 105 void setGivenName(String givenName); 106 107 String getKnownAs(); 108 void setKnownAs(String knownAs); 109 110 String getPhoneNumber(); 111 void setPhoneNumber(String phoneNumber); 112 113 void setUsername(String username); 114 115 void setEncryptedPassword(String encryptedPassword); 116 117 boolean isForSelfOrRunAsAdministrator(); 118 119 boolean isHasPassword(); 120 121 default boolean isLocalAccount() { 122 return getAccountType() == AccountType.LOCAL; 123 } 124 125}