提交 6bd2231a 编写于 作者: M MaxKey

App credential to string type

上级 9bf04827
...@@ -42,10 +42,10 @@ public class Apps extends JpaBaseEntity implements Serializable { ...@@ -42,10 +42,10 @@ public class Apps extends JpaBaseEntity implements Serializable {
private static final long serialVersionUID = -6264641546959620712L; private static final long serialVersionUID = -6264641546959620712L;
public static final class CREDENTIALS { public static final class CREDENTIALS {
public static final int USER_DEFINED = 3; public static final String USER_DEFINED = "user_defined";
public static final int SHARED = 2; public static final String SHARED = "shared";
public static final int SYSTEM = 1; public static final String SYSTEM = "system";
public static final int NONE = 0; public static final String NONE = "none";
} }
public static final class VISIBLE { public static final class VISIBLE {
...@@ -100,7 +100,7 @@ public class Apps extends JpaBaseEntity implements Serializable { ...@@ -100,7 +100,7 @@ public class Apps extends JpaBaseEntity implements Serializable {
* CREDENTIAL VALUES USER-DEFINED SYSTEM SHARED NONE * CREDENTIAL VALUES USER-DEFINED SYSTEM SHARED NONE
*/ */
@Column @Column
private int credential; private String credential;
@Column @Column
private String sharedUsername; private String sharedUsername;
@Column @Column
...@@ -116,6 +116,7 @@ public class Apps extends JpaBaseEntity implements Serializable { ...@@ -116,6 +116,7 @@ public class Apps extends JpaBaseEntity implements Serializable {
@Column @Column
private String logoutUrl; private String logoutUrl;
@Column @Column
@JsonFormat(shape = JsonFormat.Shape.STRING)
private int logoutType; private int logoutType;
/* /*
* extendAttr * extendAttr
...@@ -173,7 +174,6 @@ public class Apps extends JpaBaseEntity implements Serializable { ...@@ -173,7 +174,6 @@ public class Apps extends JpaBaseEntity implements Serializable {
public Apps() { public Apps() {
super(); super();
isSignature = ConstsBoolean.FALSE; isSignature = ConstsBoolean.FALSE;
credential = CREDENTIALS.NONE;
} }
...@@ -354,14 +354,14 @@ public class Apps extends JpaBaseEntity implements Serializable { ...@@ -354,14 +354,14 @@ public class Apps extends JpaBaseEntity implements Serializable {
/** /**
* @return the credential * @return the credential
*/ */
public int getCredential() { public String getCredential() {
return credential; return credential;
} }
/** /**
* @param credential the credential to set * @param credential the credential to set
*/ */
public void setCredential(int credential) { public void setCredential(String credential) {
this.credential = credential; this.credential = credential;
} }
......
...@@ -94,6 +94,7 @@ public class AppsOAuth20Details extends Apps { ...@@ -94,6 +94,7 @@ public class AppsOAuth20Details extends Apps {
this.setAppName(application.getAppName()); this.setAppName(application.getAppName());
this.setLoginUrl(application.getLoginUrl()); this.setLoginUrl(application.getLoginUrl());
this.setLogoutUrl(application.getLogoutUrl()); this.setLogoutUrl(application.getLogoutUrl());
this.setLogoutType(application.getLogoutType());
this.setCategory(application.getCategory()); this.setCategory(application.getCategory());
this.setProtocol(application.getProtocol()); this.setProtocol(application.getProtocol());
this.setIcon(application.getIcon()); this.setIcon(application.getIcon());
...@@ -103,6 +104,8 @@ public class AppsOAuth20Details extends Apps { ...@@ -103,6 +104,8 @@ public class AppsOAuth20Details extends Apps {
this.setVendor(application.getVendor()); this.setVendor(application.getVendor());
this.setVendorUrl(application.getVendorUrl()); this.setVendorUrl(application.getVendorUrl());
this.setVisible(application.getVisible()); this.setVisible(application.getVisible());
this.setIsAdapter(application.getIsAdapter());
this.setAdapter(application.getAdapter()); this.setAdapter(application.getAdapter());
this.setAdapterId(application.getAdapterId()); this.setAdapterId(application.getAdapterId());
this.setAdapterName(application.getAdapterName()); this.setAdapterName(application.getAdapterName());
......
...@@ -76,24 +76,24 @@ public class AuthorizeBaseEndpoint { ...@@ -76,24 +76,24 @@ public class AuthorizeBaseEndpoint {
account.setUsername(userInfo.getUsername()); account.setUsername(userInfo.getUsername());
account.setAppName(app.getAppName()); account.setAppName(app.getAppName());
if(loadApp.getCredential() == Apps.CREDENTIALS.USER_DEFINED){ if(loadApp.getCredential().equalsIgnoreCase(Apps.CREDENTIALS.USER_DEFINED)){
account = accountsService.load(new Accounts(userInfo.getId(),loadApp.getId())); account = accountsService.load(new Accounts(userInfo.getId(),loadApp.getId()));
if(account != null){ if(account != null){
account.setRelatedPassword( account.setRelatedPassword(
PasswordReciprocal.getInstance().decoder(account.getRelatedPassword())); PasswordReciprocal.getInstance().decoder(account.getRelatedPassword()));
} }
}else if(loadApp.getCredential() == Apps.CREDENTIALS.SHARED){ }else if(loadApp.getCredential().equalsIgnoreCase(Apps.CREDENTIALS.SHARED)){
account.setRelatedUsername(loadApp.getSharedUsername()); account.setRelatedUsername(loadApp.getSharedUsername());
account.setRelatedPassword(PasswordReciprocal.getInstance().decoder(loadApp.getSharedPassword())); account.setRelatedPassword(PasswordReciprocal.getInstance().decoder(loadApp.getSharedPassword()));
}else if(loadApp.getCredential() == Apps.CREDENTIALS.SYSTEM){ }else if(loadApp.getCredential().equalsIgnoreCase( Apps.CREDENTIALS.SYSTEM)){
account.setUsername( account.setUsername(
AbstractAuthorizeAdapter.getValueByUserAttr(userInfo, loadApp.getSystemUserAttr()) AbstractAuthorizeAdapter.getValueByUserAttr(userInfo, loadApp.getSystemUserAttr())
); );
//decoder database stored encode password //decoder database stored encode password
account.setRelatedPassword( account.setRelatedPassword(
PasswordReciprocal.getInstance().decoder(userInfo.getDecipherable())); PasswordReciprocal.getInstance().decoder(userInfo.getDecipherable()));
}else if(loadApp.getCredential()==Apps.CREDENTIALS.NONE){ }else if(loadApp.getCredential().equalsIgnoreCase(Apps.CREDENTIALS.NONE)){
account.setUsername(userInfo.getUsername()); account.setUsername(userInfo.getUsername());
account.setRelatedPassword(userInfo.getUsername()); account.setRelatedPassword(userInfo.getUsername());
......
...@@ -67,7 +67,7 @@ public class ExtendApiAuthorizeEndpoint extends AuthorizeBaseEndpoint{ ...@@ -67,7 +67,7 @@ public class ExtendApiAuthorizeEndpoint extends AuthorizeBaseEndpoint{
_logger.debug("Adapter {}",apps.getAdapter()); _logger.debug("Adapter {}",apps.getAdapter());
AbstractAuthorizeAdapter adapter = (AbstractAuthorizeAdapter)Instance.newInstance(apps.getAdapter()); AbstractAuthorizeAdapter adapter = (AbstractAuthorizeAdapter)Instance.newInstance(apps.getAdapter());
Accounts account = getAccounts(apps,currentUser); Accounts account = getAccounts(apps,currentUser);
if(apps.getCredential()==Apps.CREDENTIALS.USER_DEFINED && account == null) { if(apps.getCredential().equalsIgnoreCase(Apps.CREDENTIALS.USER_DEFINED) && account == null) {
return initCredentialView(id,"/authorize/api/"+id); return initCredentialView(id,"/authorize/api/"+id);
} }
......
...@@ -40,6 +40,7 @@ export class Apps extends BaseEntity { ...@@ -40,6 +40,7 @@ export class Apps extends BaseEntity {
logoutType!: String; logoutType!: String;
isExtendAttr!: String; isExtendAttr!: String;
extendAttr!: String; extendAttr!: String;
resourceMgt!: String;
userPropertys!: String; userPropertys!: String;
isSignature!: String; isSignature!: String;
isAdapter!: String; isAdapter!: String;
...@@ -54,10 +55,12 @@ export class Apps extends BaseEntity { ...@@ -54,10 +55,12 @@ export class Apps extends BaseEntity {
constructor() { constructor() {
super(); super();
this.category = 'none'; this.category = 'none';
this.frequently = 'no';
this.resourceMgt = 'false';
this.visible = '0'; this.visible = '0';
this.isAdapter = '0'; this.isAdapter = '0';
this.logoutType = '0'; this.logoutType = '0';
this.frequently = 'no'; this.isExtendAttr = '0';
} }
override init(data: any): void { override init(data: any): void {
...@@ -67,10 +70,6 @@ export class Apps extends BaseEntity { ...@@ -67,10 +70,6 @@ export class Apps extends BaseEntity {
} else { } else {
this.switch_status = false; this.switch_status = false;
} }
this.isAdapter = `${data.isAdapter}`;
this.isExtendAttr = `${data.isExtendAttr}`;
this.logoutType = `${data.logoutType}`;
this.visible = `${data.visible}`;
} }
override trans(): void { override trans(): void {
......
...@@ -86,12 +86,12 @@ public class AppListController { ...@@ -86,12 +86,12 @@ public class AppListController {
@RequestMapping(value = { "/account/get" }) @RequestMapping(value = { "/account/get" })
@ResponseBody @ResponseBody
public ResponseEntity<?> getAccount( public ResponseEntity<?> getAccount(
@RequestParam("credential") int credential, @RequestParam("credential") String credential,
@RequestParam("appId") String appId, @RequestParam("appId") String appId,
@CurrentUser UserInfo currentUser) { @CurrentUser UserInfo currentUser) {
Accounts account = null ; Accounts account = null ;
if (credential == Apps.CREDENTIALS.USER_DEFINED) { if (credential.equalsIgnoreCase(Apps.CREDENTIALS.USER_DEFINED)) {
account = accountsService.load(new Accounts(currentUser.getId(), appId)); account = accountsService.load(new Accounts(currentUser.getId(), appId));
account.setRelatedPassword( account.setRelatedPassword(
PasswordReciprocal.getInstance().decoder( PasswordReciprocal.getInstance().decoder(
...@@ -110,11 +110,11 @@ public class AppListController { ...@@ -110,11 +110,11 @@ public class AppListController {
@RequestMapping(value = { "/account/update" }) @RequestMapping(value = { "/account/update" })
@ResponseBody @ResponseBody
public ResponseEntity<?> updateAccount( public ResponseEntity<?> updateAccount(
@RequestParam("credential") int credential, @RequestParam("credential") String credential,
@ModelAttribute Accounts account, @ModelAttribute Accounts account,
@CurrentUser UserInfo currentUser) { @CurrentUser UserInfo currentUser) {
Accounts appUsers = new Accounts(); Accounts appUsers = new Accounts();
if (credential == Apps.CREDENTIALS.USER_DEFINED) { if (credential.equalsIgnoreCase(Apps.CREDENTIALS.USER_DEFINED)) {
appUsers = accountsService.load(new Accounts(currentUser.getId(), account.getAppId())); appUsers = accountsService.load(new Accounts(currentUser.getId(), account.getAppId()));
if (appUsers == null) { if (appUsers == null) {
appUsers = new Accounts(); appUsers = new Accounts();
......
...@@ -72,7 +72,7 @@ public class BaseAppContorller { ...@@ -72,7 +72,7 @@ public class BaseAppContorller {
} }
protected void encodeSharedPassword(Apps application){ protected void encodeSharedPassword(Apps application){
if(application.getCredential()!=Apps.CREDENTIALS.SHARED){ if(!application.getCredential().equalsIgnoreCase(Apps.CREDENTIALS.SHARED)){
if(application.getProtocol().equals(ConstsProtocols.FORMBASED)){ if(application.getProtocol().equals(ConstsProtocols.FORMBASED)){
if(StringUtils.isNotBlank(application.getSharedPassword())){ if(StringUtils.isNotBlank(application.getSharedPassword())){
application.setSharedPassword( application.setSharedPassword(
...@@ -83,7 +83,7 @@ public class BaseAppContorller { ...@@ -83,7 +83,7 @@ public class BaseAppContorller {
} }
protected void decoderSharedPassword(Apps application){ protected void decoderSharedPassword(Apps application){
if(application.getCredential()!=Apps.CREDENTIALS.SHARED){ if(application.getCredential().equalsIgnoreCase(Apps.CREDENTIALS.SHARED)){
if(application.getProtocol().equals(ConstsProtocols.FORMBASED)){ if(application.getProtocol().equals(ConstsProtocols.FORMBASED)){
if(StringUtils.isNotBlank(application.getSharedPassword())){ if(StringUtils.isNotBlank(application.getSharedPassword())){
application.setSharedPassword( application.setSharedPassword(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册