client details register

2.0.0
monkeyk7 2018-04-21 16:28:58 +08:00
parent 4ac0eff40e
commit c4fc969b9a
3 changed files with 16 additions and 7 deletions

View File

@ -1,5 +1,7 @@
package com.monkeyk.sos.domain.shared;
import org.springframework.security.oauth2.common.util.RandomValueStringGenerator;
import java.util.UUID;
/**
@ -8,6 +10,9 @@ import java.util.UUID;
public abstract class GuidGenerator {
private static RandomValueStringGenerator defaultClientSecretGenerator = new RandomValueStringGenerator(32);
/**
* private constructor
*/
@ -17,4 +22,9 @@ public abstract class GuidGenerator {
public static String generate() {
return UUID.randomUUID().toString().replaceAll("-", "");
}
public static String generateClientSecret() {
return defaultClientSecretGenerator.generate();
}
}

View File

@ -1,6 +1,7 @@
package com.monkeyk.sos.service.dto;
import com.monkeyk.sos.domain.oauth.OauthClientDetails;
import com.monkeyk.sos.domain.shared.GuidGenerator;
import com.monkeyk.sos.infrastructure.DateUtils;
import org.apache.commons.lang.StringUtils;
@ -17,10 +18,10 @@ public class OauthClientDetailsDto implements Serializable {
private String createTime;
private boolean archived;
private String clientId;
private String clientId = GuidGenerator.generate();
private String resourceIds;
private String clientSecret;
private String clientSecret = GuidGenerator.generateClientSecret();
private String scope;

View File

@ -56,12 +56,10 @@
<div class="col-sm-10">
<form:select path="resourceIds" cssClass="form-control" id="resourceIds">
<form:option value="unity-resource">unity-resource</form:option>
<form:option value="mobile-resource">mobile-resource</form:option>
<form:option value="unity-resource,mobile-resource">unity-resource,mobile-resource</form:option>
<form:option value="sos-resource">sos-resource</form:option>
</form:select>
<p class="help-block">resourceIds必须选择; 可选值必须来源于与<code>security.xml</code>中标签<code>&lsaquo;oauth2:resource-server</code>的属性<code>resource-id</code>
<p class="help-block">resourceIds必须选择; 可选值必须来源于与<code>OAuth2ServerConfiguration.java</code>中固定
</p>
</div>
</div>
@ -73,7 +71,7 @@
<form:select path="scope" id="scope" cssClass="form-control">
<form:option value="read">read</form:option>
<form:option value="write">write</form:option>
<form:option value="read,write">read write</form:option>
<form:option value="read,write">read,write</form:option>
</form:select>
<p class="help-block">scope必须选择</p>