1 /* 2 * Copyright (c) 2008 Sonatype, Inc. All rights reserved. 3 * 4 * This program is licensed to you under the Apache License Version 2.0, 5 * and you may not use this file except in compliance with the Apache License Version 2.0. 6 * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. 7 * 8 * Unless required by applicable law or agreed to in writing, 9 * software distributed under the Apache License Version 2.0 is distributed on an 10 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. 12 */ 13 14 package org.codehaus.plexus.components.secdispatcher; 15 16 /** 17 * Source of master password. 18 */ 19 public interface MasterSource { 20 /** 21 * Handles the config to get master password. Implementation may do one of the following things: 22 * <ul> 23 * <li>if the config cannot be handled by given source, return {@code null}</li> 24 * <li>otherwise, if master password retrieval based on config was attempted but failed, throw {@link SecDispatcherException}</li> 25 * <li>happy path: return the master password.</li> 26 * </ul> 27 * 28 * @param config the source of master password, and opaque string. 29 * @return the master password, or {@code null} if implementation does not handle this config 30 * @throws SecDispatcherException If implementation does handle this masterSource, but cannot obtain master password 31 */ 32 String handle(String config) throws SecDispatcherException; 33 34 /** 35 * Validates master source configuration. 36 * <ul> 37 * <li>if the config cannot be handled by given source, return {@code null}</li> 38 * <li>otherwise, implementation performs validation and returns non-{@code null} validation response</li> 39 * </ul> 40 */ 41 SecDispatcher.ValidationResponse validateConfiguration(String config); 42 }