Outh working!. Pending:
- Test all databases - Migration Scripts - Manage error due to changing of authentication schemas. - Link from the login page. - What happend with the logout ?.
This commit is contained in:
@@ -1,17 +1,33 @@
|
||||
package com.wisemapping.model;
|
||||
|
||||
public enum AuthenticationSchema
|
||||
{
|
||||
DATABASE(0),
|
||||
LDAP(1),
|
||||
OPENID(2);
|
||||
private final int schemaCode;
|
||||
public enum AuthenticationSchema {
|
||||
DATABASE('D'),
|
||||
LDAP('L'),
|
||||
OPENID('O');
|
||||
private final char schemaCode;
|
||||
|
||||
AuthenticationSchema(int schemaCode) {
|
||||
AuthenticationSchema(char schemaCode) {
|
||||
this.schemaCode = schemaCode;
|
||||
}
|
||||
|
||||
public int getSchemaCode() {
|
||||
public char getCode() {
|
||||
return schemaCode;
|
||||
}
|
||||
|
||||
public static AuthenticationSchema valueOf(char code) {
|
||||
AuthenticationSchema result = null;
|
||||
AuthenticationSchema[] values = AuthenticationSchema.values();
|
||||
for (AuthenticationSchema value : values) {
|
||||
if (value.getCode() == code) {
|
||||
result = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
throw new IllegalStateException("Could not find auth with code:" + code);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.wisemapping.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -36,9 +37,8 @@ public class User
|
||||
private Calendar activationDate;
|
||||
private Set<String> tags = new HashSet<String>();
|
||||
private boolean allowSendEmail = false;
|
||||
private int schema;
|
||||
private String locale;
|
||||
|
||||
private AuthenticationSchema authenticationSchema;
|
||||
|
||||
public User() {
|
||||
}
|
||||
@@ -116,11 +116,25 @@ public class User
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public int getAutheticationCode() {
|
||||
return this.schema;
|
||||
public char getAutheticationCode() {
|
||||
return this.authenticationSchema != null ? this.authenticationSchema.getCode() : null;
|
||||
}
|
||||
|
||||
public void setAuthenticationCode(int code) {
|
||||
this.schema = code;
|
||||
public void setAutheticationCode(char code) {
|
||||
this.authenticationSchema = AuthenticationSchema.valueOf(code);
|
||||
}
|
||||
|
||||
public AuthenticationSchema getAuthenticationSchema() {
|
||||
return authenticationSchema;
|
||||
}
|
||||
|
||||
public void setAuthenticationSchema(@NotNull AuthenticationSchema authenticationSchema) {
|
||||
this.authenticationSchema = authenticationSchema;
|
||||
}
|
||||
|
||||
public boolean isDatabaseSchema(){
|
||||
return this.authenticationSchema==AuthenticationSchema.DATABASE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user