001package org.apache.archiva.redback.rbac.memory; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.archiva.redback.rbac.AbstractUserAssignment; 023import org.apache.archiva.redback.rbac.UserAssignment; 024 025import java.util.ArrayList; 026import java.util.List; 027 028/** 029 * MemoryUserAssignment 030 * 031 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> 032 * 033 */ 034public class MemoryUserAssignment 035 extends AbstractUserAssignment 036 implements UserAssignment, java.io.Serializable 037{ 038 039 /** 040 * Field principal 041 */ 042 private String principal; 043 044 /** 045 * Field roles 046 */ 047 private List<String> roles = new ArrayList<String>( 0 ); 048 049 /** 050 * Field permanent 051 */ 052 private boolean permanent = false; 053 054 /** 055 * Method equals 056 * 057 * @param other 058 */ 059 public boolean equals( Object other ) 060 { 061 if ( this == other ) 062 { 063 return true; 064 } 065 066 if ( !( other instanceof MemoryUserAssignment ) ) 067 { 068 return false; 069 } 070 071 MemoryUserAssignment that = (MemoryUserAssignment) other; 072 boolean result = true; 073 result = result && ( getPrincipal() == null 074 ? that.getPrincipal() == null 075 : getPrincipal().equals( that.getPrincipal() ) ); 076 return result; 077 } 078 079 /** 080 * Get null 081 */ 082 public String getPrincipal() 083 { 084 return this.principal; 085 } 086 087 /** 088 * Method getRoles 089 */ 090 public List<String> getRoleNames() 091 { 092 if ( this.roles == null ) 093 { 094 this.roles = new ArrayList<String>( 0 ); 095 } 096 097 return this.roles; 098 } 099 100 @Override 101 public List<String> getRoleIds( ) 102 { 103 if ( this.roles == null ) 104 { 105 this.roles = new ArrayList<String>( 0 ); 106 } 107 108 return this.roles; 109 } 110 111 /** 112 * Method hashCode 113 */ 114 public int hashCode() 115 { 116 int result = 17; 117 result = 37 * result + ( principal != null ? principal.hashCode() : 0 ); 118 return result; 119 } 120 121 /** 122 * Set null 123 * 124 * @param principal 125 */ 126 public void setPrincipal( String principal ) 127 { 128 this.principal = principal; 129 } 130 131 /** 132 * Set null 133 * 134 * @param roles 135 */ 136 public void setRoleNames( List<String> roles ) 137 { 138 this.roles = roles; 139 } 140 141 @Override 142 public void setRoleIds( List<String> roles ) 143 { 144 this.roles = roles; 145 } 146 147 /** 148 * Method toString 149 */ 150 public java.lang.String toString() 151 { 152 StringBuilder buf = new StringBuilder(); 153 buf.append( "principal = '" ); 154 buf.append( getPrincipal() + "'" ); 155 return buf.toString(); 156 } 157 158 public boolean isPermanent() 159 { 160 return permanent; 161 } 162 163 public void setPermanent( boolean permanent ) 164 { 165 this.permanent = permanent; 166 } 167}