54 lines
1.2 KiB
Java
54 lines
1.2 KiB
Java
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<Secret> authorizationSecrets;
|
|
|
|
public SecretHolder() {
|
|
this.authorizationSecrets = new TreeSet<Secret>();
|
|
}
|
|
|
|
public SecretHolder(Collection<Secret> authorizationSecrets) {
|
|
this.authorizationSecrets = new TreeSet<Secret>(authorizationSecrets);
|
|
}
|
|
|
|
public void addAuthorizationSecret(Secret authorizationSecret) {
|
|
if(authorizationSecret!=null) {
|
|
authorizationSecrets.add(authorizationSecret);
|
|
}
|
|
}
|
|
|
|
public SortedSet<Secret> 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;
|
|
}
|
|
|
|
}
|