package org.gcube.common.authorization.utils.manager; import java.util.Collection; import java.util.SortedSet; import java.util.TreeSet; import org.gcube.common.authorization.utils.secret.Secret; public class SecretHolder { private SortedSet authorizationSecrets; public SecretHolder() { this.authorizationSecrets = new TreeSet(); } public SecretHolder(Collection authorizationSecrets) { this.authorizationSecrets = new TreeSet(authorizationSecrets); } public void addAuthorizationSecret(Secret authorizationSecret) { if(authorizationSecret!=null) { authorizationSecrets.add(authorizationSecret); } } public SortedSet getAuthorizationSecrets() { return authorizationSecrets; } public String getUsername() { for(Secret authorizationSecret : authorizationSecrets) { try { return authorizationSecret.getUsername(); }catch (Exception e) { // trying the next one } } return null; } public String getContext() { for(Secret authorizationSecret : authorizationSecrets) { try { return authorizationSecret.getContext(); }catch (Exception e) { // trying the next one } } return null; } }