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

App credential to string type

上级 9bf04827
......@@ -42,10 +42,10 @@ public class Apps extends JpaBaseEntity implements Serializable {
private static final long serialVersionUID = -6264641546959620712L;
public static final class CREDENTIALS {
public static final int USER_DEFINED = 3;
public static final int SHARED = 2;
public static final int SYSTEM = 1;
public static final int NONE = 0;
public static final String USER_DEFINED = "user_defined";
public static final String SHARED = "shared";
public static final String SYSTEM = "system";
public static final String NONE = "none";
}
public static final class VISIBLE {
......@@ -100,7 +100,7 @@ public class Apps extends JpaBaseEntity implements Serializable {
* CREDENTIAL VALUES USER-DEFINED SYSTEM SHARED NONE
*/
@Column
private int credential;
private String credential;
@Column
private String sharedUsername;
@Column
......@@ -116,6 +116,7 @@ public class Apps extends JpaBaseEntity implements Serializable {
@Column
private String logoutUrl;
@Column
@JsonFormat(shape = JsonFormat.Shape.STRING)
private int logoutType;
/*
* extendAttr
......@@ -173,7 +174,6 @@ public class Apps extends JpaBaseEntity implements Serializable {
public Apps() {
super();
isSignature = ConstsBoolean.FALSE;
credential = CREDENTIALS.NONE;
}
......@@ -354,14 +354,14 @@ public class Apps extends JpaBaseEntity implements Serializable {
/**
* @return the credential
*/
public int getCredential() {
public String getCredential() {
return credential;
}
/**
* @param credential the credential to set
*/
public void setCredential(int credential) {
public void setCredential(String credential) {
this.credential = credential;
}
......
......@@ -94,6 +94,7 @@ public class AppsOAuth20Details extends Apps {
this.setAppName(application.getAppName());
this.setLoginUrl(application.getLoginUrl());
this.setLogoutUrl(application.getLogoutUrl());
this.setLogoutType(application.getLogoutType());
this.setCategory(application.getCategory());
this.setProtocol(application.getProtocol());
this.setIcon(application.getIcon());
......@@ -103,6 +104,8 @@ public class AppsOAuth20Details extends Apps {
this.setVendor(application.getVendor());
this.setVendorUrl(application.getVendorUrl());
this.setVisible(application.getVisible());
this.setIsAdapter(application.getIsAdapter());
this.setAdapter(application.getAdapter());
this.setAdapterId(application.getAdapterId());
this.setAdapterName(application.getAdapterName());
......
......@@ -76,24 +76,24 @@ public class AuthorizeBaseEndpoint {
account.setUsername(userInfo.getUsername());
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()));
if(account != null){
account.setRelatedPassword(
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.setRelatedPassword(PasswordReciprocal.getInstance().decoder(loadApp.getSharedPassword()));
}else if(loadApp.getCredential() == Apps.CREDENTIALS.SYSTEM){
}else if(loadApp.getCredential().equalsIgnoreCase( Apps.CREDENTIALS.SYSTEM)){
account.setUsername(
AbstractAuthorizeAdapter.getValueByUserAttr(userInfo, loadApp.getSystemUserAttr())
);
//decoder database stored encode password
account.setRelatedPassword(
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.setRelatedPassword(userInfo.getUsername());
......
......@@ -67,7 +67,7 @@ public class ExtendApiAuthorizeEndpoint extends AuthorizeBaseEndpoint{
_logger.debug("Adapter {}",apps.getAdapter());
AbstractAuthorizeAdapter adapter = (AbstractAuthorizeAdapter)Instance.newInstance(apps.getAdapter());
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);
}
......
......@@ -19,65 +19,64 @@ import format from 'date-fns/format';
import { BaseEntity } from './BaseEntity';
export class Apps extends BaseEntity {
appName!: String;
loginUrl!: String;
category!: String;
protocol!: String;
secret!: String;
iconBase64!: String;
visible!: String;
inducer!: String;
vendor!: String;
vendorUrl!: String;
credential!: String;
sharedUsername!: String;
sharedPassword!: String;
systemUserAttr!: String;
principal!: String;
credentials!: String;
appName!: String;
loginUrl!: String;
category!: String;
protocol!: String;
secret!: String;
iconBase64!: String;
visible!: String;
inducer!: String;
vendor!: String;
vendorUrl!: String;
credential!: String;
sharedUsername!: String;
sharedPassword!: String;
systemUserAttr!: String;
principal!: String;
credentials!: String;
logoutUrl!: String;
logoutType!: String;
isExtendAttr!: String;
extendAttr!: String;
userPropertys!: String;
isSignature!: String;
isAdapter!: String;
adapterId!: String;
adapterName!: String;
adapter!: String;
iconId!: String;
frequently!: String;
logoutUrl!: String;
logoutType!: String;
isExtendAttr!: String;
extendAttr!: String;
resourceMgt!: String;
userPropertys!: String;
isSignature!: String;
isAdapter!: String;
adapterId!: String;
adapterName!: String;
adapter!: String;
iconId!: String;
frequently!: String;
select_userPropertys!: String[];
select_userPropertys!: String[];
constructor() {
super();
this.category = 'none';
this.visible = '0';
this.isAdapter = '0';
this.logoutType = '0';
this.frequently = 'no';
}
constructor() {
super();
this.category = 'none';
this.frequently = 'no';
this.resourceMgt = 'false';
this.visible = '0';
this.isAdapter = '0';
this.logoutType = '0';
this.isExtendAttr = '0';
}
override init(data: any): void {
Object.assign(this, data);
if (this.status == 1) {
this.switch_status = true;
} else {
this.switch_status = false;
}
this.isAdapter = `${data.isAdapter}`;
this.isExtendAttr = `${data.isExtendAttr}`;
this.logoutType = `${data.logoutType}`;
this.visible = `${data.visible}`;
override init(data: any): void {
Object.assign(this, data);
if (this.status == 1) {
this.switch_status = true;
} else {
this.switch_status = false;
}
}
override trans(): void {
if (this.switch_status) {
this.status = 1;
} else {
this.status = 0;
}
override trans(): void {
if (this.switch_status) {
this.status = 1;
} else {
this.status = 0;
}
}
}
......@@ -86,12 +86,12 @@ public class AppListController {
@RequestMapping(value = { "/account/get" })
@ResponseBody
public ResponseEntity<?> getAccount(
@RequestParam("credential") int credential,
@RequestParam("credential") String credential,
@RequestParam("appId") String appId,
@CurrentUser UserInfo currentUser) {
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.setRelatedPassword(
PasswordReciprocal.getInstance().decoder(
......@@ -110,11 +110,11 @@ public class AppListController {
@RequestMapping(value = { "/account/update" })
@ResponseBody
public ResponseEntity<?> updateAccount(
@RequestParam("credential") int credential,
@RequestParam("credential") String credential,
@ModelAttribute Accounts account,
@CurrentUser UserInfo currentUser) {
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()));
if (appUsers == null) {
appUsers = new Accounts();
......
......@@ -72,7 +72,7 @@ public class BaseAppContorller {
}
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(StringUtils.isNotBlank(application.getSharedPassword())){
application.setSharedPassword(
......@@ -83,7 +83,7 @@ public class BaseAppContorller {
}
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(StringUtils.isNotBlank(application.getSharedPassword())){
application.setSharedPassword(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册