001/*
002 * (C) Copyright 2011 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 *    Wojciech Sulejman
018 */
019package org.nuxeo.ecm.platform.signature.api.user;
020
021/**
022 * Represents a keystore alias.
023 * <p>
024 * Provides methods for binding a keystore alias name with userID and alias type.
025 *
026 * @author <a href="mailto:ws@nuxeo.com">Wojciech Sulejman</a>
027 */
028public class AliasWrapper {
029    private String userName;
030
031    /**
032     * Public constructor for the AliasWrapper. Used to associate a user name with an AliasWrapper object. The userName
033     * constitutes the first part of the AliasWrapper's identity. The second part of the identity is based on an
034     * AliasType provided as a parameter. E.g., for a user identified by string "jdoe" and using a type "cert", the
035     * produced alias string would be "jdoecert".
036     */
037    public AliasWrapper(String userName) {
038        this.userName = userName;
039    }
040
041    /**
042     * Provides the user name associated with the alias for generic checking of alias groups (an alias group would share
043     * the name, not the id).
044     */
045    public String getUserName() {
046        return userName;
047    }
048
049    /**
050     * Returns a unique identifier for the keystore alias.
051     */
052    public String getId(AliasType type) {
053        return userName + type.toString();
054    }
055}