sorting on approval page
parent
328fa221bd
commit
d0fdf8140e
|
@ -133,6 +133,74 @@ public class SystemScope {
|
||||||
this.defaultScope = defaultScope;
|
this.defaultScope = defaultScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#hashCode()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + (allowDynReg ? 1231 : 1237);
|
||||||
|
result = prime * result + (defaultScope ? 1231 : 1237);
|
||||||
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
|
result = prime * result + ((icon == null) ? 0 : icon.hashCode());
|
||||||
|
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||||
|
result = prime * result + ((value == null) ? 0 : value.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SystemScope other = (SystemScope) obj;
|
||||||
|
if (allowDynReg != other.allowDynReg) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (defaultScope != other.defaultScope) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (description == null) {
|
||||||
|
if (other.description != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!description.equals(other.description)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (icon == null) {
|
||||||
|
if (other.icon != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!icon.equals(other.icon)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (id == null) {
|
||||||
|
if (other.id != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!id.equals(other.id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
if (other.value != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!value.equals(other.value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.mitre.oauth2.web;
|
package org.mitre.oauth2.web;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -36,6 +37,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jricher
|
* @author jricher
|
||||||
*
|
*
|
||||||
|
@ -88,7 +91,19 @@ public class OAuthConfirmationController {
|
||||||
|
|
||||||
Set<SystemScope> scopes = scopeService.fromStrings(clientAuth.getScope());
|
Set<SystemScope> scopes = scopeService.fromStrings(clientAuth.getScope());
|
||||||
|
|
||||||
model.put("scopes", scopes);
|
Set<SystemScope> sortedScopes = new LinkedHashSet<SystemScope>(scopes.size());
|
||||||
|
Set<SystemScope> systemScopes = scopeService.getAll();
|
||||||
|
|
||||||
|
// sort scopes for display
|
||||||
|
for (SystemScope s : systemScopes) {
|
||||||
|
if (scopes.contains(s)) {
|
||||||
|
sortedScopes.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sortedScopes.addAll(Sets.difference(scopes, systemScopes));
|
||||||
|
|
||||||
|
model.put("scopes", sortedScopes);
|
||||||
|
|
||||||
return new ModelAndView("oauth/approve", model);
|
return new ModelAndView("oauth/approve", model);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue