001package org.apache.archiva.redback.integration.model;
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.Permission;
023import org.apache.archiva.redback.rbac.Role;
024
025/**
026 * EditRoleDetails - Existing user Role Details.
027 *
028 * This is a placeholder for information passed back
029 * and forth between the Action and the Client.
030 *
031 * We intentionally do not hook up the actual object to prevent
032 * creative injection of fields and values by the untrusted client.
033 *
034 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
035 *
036 */
037public class EditRoleDetails
038    extends RoleDetails
039{
040    public EditRoleDetails( Role role )
041    {
042        super.setName( role.getName() );
043        super.setDescription( role.getDescription() );
044        
045        for ( String r : role.getChildRoleNames() )
046        {
047            super.addChildRoleName( r );
048        }
049
050        for ( Permission perm : role.getPermissions() )
051        {
052            super.addPermission( perm.getName(), perm.getOperation().getName(), perm.getResource().getIdentifier() );
053        }
054    }
055
056    public void setName( String name )
057    {
058        // Prevent Change (This is an edit after all)
059    }
060}