
org.paranora.ssoc.token.TokenRequestAbstract Maven / Gradle / Ivy
package org.paranora.ssoc.token;
import java.util.*;
public class TokenRequestAbstract implements TokenRequest{
private String grantType;
private String clientId;
private Set scope = new HashSet();
private Map requestParameters = Collections.unmodifiableMap(new HashMap());
protected TokenRequestAbstract() {
}
public TokenRequestAbstract(String clientId, String grantType, Collection scope, Map requestParameters) {
setClientId(clientId);
setRequestParameters(requestParameters);
setScope(scope);
this.grantType = grantType;
}
public String getGrantType() {
return grantType;
}
public void setGrantType(String grantType) {
this.grantType = grantType;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getClientId() {
return clientId;
}
public void setScope(Collection scope) {
if (scope != null && scope.size() == 1) {
String value = scope.iterator().next();
if (value.contains(" ") || value.contains(",")) {
scope = parseParameterList(value);
}
}
this.scope = Collections
.unmodifiableSet(scope == null ? new LinkedHashSet()
: new LinkedHashSet(scope));
}
public Set getScope() {
return scope;
}
protected Set parseParameterList(String values) {
Set result = new TreeSet();
if (values != null && values.trim().length() > 0) {
// the spec says the scope is separated by spaces
String[] tokens = values.split("[\\s+]");
result.addAll(Arrays.asList(tokens));
}
return result;
}
public void setRequestParameters(Map requestParameters) {
if (requestParameters != null) {
this.requestParameters = Collections.unmodifiableMap(new HashMap(requestParameters));
}
}
public Map getRequestParameters() {
return requestParameters;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy