View Javadoc

1   /**
2    * Copyright (C) 2005-2009 Alfresco Software Limited.
3    *
4    * This file is part of the Spring Surf Extension project.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *  http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.springframework.extensions.webscripts.connector;
20  
21  /**
22   * Interface for a Credential Vault
23   * 
24   * Credential vaults allow for the storage and retrieval of credentials by
25   * credential id.
26   * 
27   * They can also be loaded and saved if they are backed by a persisted storage
28   * location.
29   * 
30   * @author muzquiano
31   */
32  public interface CredentialVault
33  {
34      /**
35       * Places the given credentials into the vault
36       * 
37       * @param credentials the credentials
38       */
39      public void store(Credentials credentials);
40  
41      /**
42       * Retrieves credentials for a given endpoint id from the vault
43       * 
44       * @param endpointId the endpoint id
45       * 
46       * @return the credentials
47       */
48      public Credentials retrieve(String endpointId);
49      
50      /**
51       * Removes credentials for a given endpoint id from the vault
52       * @param endpointId
53       */
54      public void remove(String endpointId);
55      
56      /**
57       * @return true if any credentials are stored for this endpoint id
58       */
59      public boolean hasCredentials(String endpointId);
60  
61      /**
62       * Creates new credentials which are stored in this vault
63       * 
64       * @param endpointId
65       * @return the credentials object
66       */
67      public Credentials newCredentials(String endpointId);
68      
69      /**
70       * Returns the ids for stored credentials
71       * 
72       * @return
73       */
74      public String[] getStoredIds();
75      
76      /**
77       * Tells the Credential Vault to load state from persisted store
78       * 
79       * @return whether the credential vault successfully loaded
80       */
81      public boolean load();
82  
83      /**
84       * Tells the Credential Vault to write state to persisted store
85       * 
86       * @return whether the credential vault successfully saved
87       */
88      public boolean save();
89  }