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     * @param userName
038     */
039    public AliasWrapper(String userName) {
040        this.userName = userName;
041    }
042
043    /**
044     * Provides the user name associated with the alias for generic checking of alias groups (an alias group would share
045     * the name, not the id).
046     *
047     * @return
048     */
049    public String getUserName() {
050        return userName;
051    }
052
053    /**
054     * Returns a unique identifier for the keystore alias.
055     */
056    public String getId(AliasType type) {
057        return userName + type.toString();
058    }
059}