001package org.apache.archiva.redback.authorization;
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.users.User;
023
024/**
025 * @author Jason van Zyl
026 */
027public class AuthorizationDataSource
028{
029    private String principal;
030
031    private User user;
032
033    private String permission;
034
035    private String resource;
036
037    public AuthorizationDataSource( String principal, User user, String permission )
038    {
039        this.principal = principal;
040        this.user = user;
041        this.permission = permission;
042    }
043
044    public AuthorizationDataSource( String principal, User user, String permission, String resource )
045    {
046        this.principal = principal;
047        this.user = user;
048        this.permission = permission;
049        this.resource = resource;
050    }
051
052    public String getPrincipal()
053    {
054        return principal;
055    }
056
057    public void setPrincipal( String principal )
058    {
059        this.principal = principal;
060    }
061
062    public User getUser()
063    {
064        return user;
065    }
066
067    public void setUser( User user )
068    {
069        this.user = user;
070    }
071
072    public String getPermission()
073    {
074        return permission;
075    }
076
077    public void setPermission( String permission )
078    {
079        this.permission = permission;
080    }
081
082    public String getResource()
083    {
084        return resource;
085    }
086
087    public void setResource( String resource )
088    {
089        this.resource = resource;
090    }
091
092    @Override
093    public String toString()
094    {
095        final StringBuilder sb = new StringBuilder();
096        sb.append( "AuthorizationDataSource" );
097        sb.append( "{principal='" ).append( principal ).append( '\'' );
098        // not display password in logs
099        //sb.append( ", user=" ).append( user );
100        sb.append( ", permission='" ).append( permission ).append( '\'' );
101        sb.append( ", resource='" ).append( resource ).append( '\'' );
102        sb.append( '}' );
103        return sb.toString();
104    }
105}