mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-05 07:03:24 +01:00
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:
parent
2f8df725c9
commit
94356a5773
@ -6,6 +6,7 @@ creation_date date);
|
|||||||
CREATE TABLE USER (
|
CREATE TABLE USER (
|
||||||
id INTEGER NOT NULL IDENTITY,
|
id INTEGER NOT NULL IDENTITY,
|
||||||
colaborator_id INTEGER NOT NULL,
|
colaborator_id INTEGER NOT NULL,
|
||||||
|
auth_schema CHAR(1) NOT NULL,
|
||||||
firstname varchar(255) NOT NULL,
|
firstname varchar(255) NOT NULL,
|
||||||
lastname varchar(255) NOT NULL,
|
lastname varchar(255) NOT NULL,
|
||||||
password varchar(255) NOT NULL,
|
password varchar(255) NOT NULL,
|
||||||
|
@ -1,17 +1,33 @@
|
|||||||
package com.wisemapping.model;
|
package com.wisemapping.model;
|
||||||
|
|
||||||
public enum AuthenticationSchema
|
public enum AuthenticationSchema {
|
||||||
{
|
DATABASE('D'),
|
||||||
DATABASE(0),
|
LDAP('L'),
|
||||||
LDAP(1),
|
OPENID('O');
|
||||||
OPENID(2);
|
private final char schemaCode;
|
||||||
private final int schemaCode;
|
|
||||||
|
|
||||||
AuthenticationSchema(int schemaCode) {
|
AuthenticationSchema(char schemaCode) {
|
||||||
this.schemaCode = schemaCode;
|
this.schemaCode = schemaCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSchemaCode() {
|
public char getCode() {
|
||||||
return schemaCode;
|
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;
|
package com.wisemapping.model;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -36,9 +37,8 @@ public class User
|
|||||||
private Calendar activationDate;
|
private Calendar activationDate;
|
||||||
private Set<String> tags = new HashSet<String>();
|
private Set<String> tags = new HashSet<String>();
|
||||||
private boolean allowSendEmail = false;
|
private boolean allowSendEmail = false;
|
||||||
private int schema;
|
|
||||||
private String locale;
|
private String locale;
|
||||||
|
private AuthenticationSchema authenticationSchema;
|
||||||
|
|
||||||
public User() {
|
public User() {
|
||||||
}
|
}
|
||||||
@ -116,11 +116,25 @@ public class User
|
|||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAutheticationCode() {
|
public char getAutheticationCode() {
|
||||||
return this.schema;
|
return this.authenticationSchema != null ? this.authenticationSchema.getCode() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthenticationCode(int code) {
|
public void setAutheticationCode(char code) {
|
||||||
this.schema = 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
package com.wisemapping.rest;
|
package com.wisemapping.rest;
|
||||||
|
|
||||||
import com.wisemapping.exceptions.ClientException;
|
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
|
import com.wisemapping.model.AuthenticationSchema;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
import com.wisemapping.rest.model.RestUser;
|
import com.wisemapping.rest.model.RestUser;
|
||||||
import com.wisemapping.service.UserService;
|
import com.wisemapping.service.UserService;
|
||||||
@ -85,7 +85,8 @@ public class AdminController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Finally create the user ...
|
// Finally create the user ...
|
||||||
userService.createUser(delegated, false,true);
|
delegated.setAuthenticationSchema(AuthenticationSchema.DATABASE);
|
||||||
|
userService.createUser(delegated, false, true);
|
||||||
response.setHeader("Location", "/service/admin/users/" + user.getId());
|
response.setHeader("Location", "/service/admin/users/" + user.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ public class AdminController extends BaseController {
|
|||||||
userService.changePassword(user);
|
userService.changePassword(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.DELETE,value = "admin/users/{id}")
|
@RequestMapping(method = RequestMethod.DELETE, value = "admin/users/{id}")
|
||||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||||
public void getUserByEmail(@PathVariable long id) throws WiseMappingException {
|
public void getUserByEmail(@PathVariable long id) throws WiseMappingException {
|
||||||
final User user = userService.getUserBy(id);
|
final User user = userService.getUserBy(id);
|
||||||
|
@ -20,6 +20,7 @@ package com.wisemapping.security;
|
|||||||
|
|
||||||
|
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
|
import com.wisemapping.model.AuthenticationSchema;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
import com.wisemapping.service.UserService;
|
import com.wisemapping.service.UserService;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -62,6 +63,7 @@ public class UserDetailsService
|
|||||||
result = dbUser;
|
result = dbUser;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
tUser.setAuthenticationSchema(AuthenticationSchema.OPENID);
|
||||||
result = userService.createUser(tUser, false, false);
|
result = userService.createUser(tUser, false, false);
|
||||||
} catch (WiseMappingException e) {
|
} catch (WiseMappingException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
|
@ -2,6 +2,7 @@ package com.wisemapping.security.ldap;
|
|||||||
|
|
||||||
|
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
|
import com.wisemapping.model.AuthenticationSchema;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
import com.wisemapping.security.UserDetails;
|
import com.wisemapping.security.UserDetails;
|
||||||
import com.wisemapping.service.UserService;
|
import com.wisemapping.service.UserService;
|
||||||
@ -64,6 +65,7 @@ public class LdapUserDetailsContextMapper implements UserDetailsContextMapper {
|
|||||||
user.setActivationDate(now);
|
user.setActivationDate(now);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
user.setAuthenticationSchema(AuthenticationSchema.LDAP);
|
||||||
user = userService.createUser(user, false, false);
|
user = userService.createUser(user, false, false);
|
||||||
} catch (WiseMappingException e) {
|
} catch (WiseMappingException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2012] [wisemapping]
|
||||||
|
*
|
||||||
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the license at
|
||||||
|
*
|
||||||
|
* http://www.wisemapping.org/license
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.wisemapping.service;
|
||||||
|
|
||||||
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
|
|
||||||
|
public class InvalidAuthSchemaException extends WiseMappingException
|
||||||
|
{
|
||||||
|
public InvalidAuthSchemaException(String msg)
|
||||||
|
{
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
@ -36,7 +36,7 @@ public interface UserService {
|
|||||||
|
|
||||||
public void updateUser(User user);
|
public void updateUser(User user);
|
||||||
|
|
||||||
public void resetPassword(@NotNull String email) throws InvalidUserEmailException;
|
public void resetPassword(@NotNull String email) throws InvalidUserEmailException, InvalidAuthSchemaException;
|
||||||
|
|
||||||
public void deleteUser(@NotNull User user);
|
public void deleteUser(@NotNull User user);
|
||||||
|
|
||||||
|
@ -19,12 +19,10 @@
|
|||||||
package com.wisemapping.service;
|
package com.wisemapping.service;
|
||||||
|
|
||||||
import com.wisemapping.dao.UserManager;
|
import com.wisemapping.dao.UserManager;
|
||||||
|
import com.wisemapping.exceptions.ClientException;
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
import com.wisemapping.mail.NotificationService;
|
import com.wisemapping.mail.NotificationService;
|
||||||
import com.wisemapping.model.AccessAuditory;
|
import com.wisemapping.model.*;
|
||||||
import com.wisemapping.model.Collaborator;
|
|
||||||
import com.wisemapping.model.Mindmap;
|
|
||||||
import com.wisemapping.model.User;
|
|
||||||
import org.apache.velocity.app.VelocityEngine;
|
import org.apache.velocity.app.VelocityEngine;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
@ -59,9 +57,14 @@ public class UserServiceImpl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetPassword(@NotNull String email)
|
public void resetPassword(@NotNull String email)
|
||||||
throws InvalidUserEmailException {
|
throws InvalidUserEmailException, InvalidAuthSchemaException {
|
||||||
final User user = userManager.getUserBy(email);
|
final User user = userManager.getUserBy(email);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
|
||||||
|
if (user.getAuthenticationSchema() != AuthenticationSchema.DATABASE) {
|
||||||
|
throw new InvalidAuthSchemaException("Could not change password for " + user.getAuthenticationSchema().getCode());
|
||||||
|
}
|
||||||
|
|
||||||
// Generate a random password ...
|
// Generate a random password ...
|
||||||
final String password = randomstring(8, 10);
|
final String password = randomstring(8, 10);
|
||||||
user.setPassword(password);
|
user.setPassword(password);
|
||||||
@ -107,6 +110,7 @@ public class UserServiceImpl
|
|||||||
userManager.auditLogin(accessAuditory);
|
userManager.auditLogin(accessAuditory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public User createUser(@NotNull User user, boolean emailConfirmEnabled, boolean welcomeEmail) throws WiseMappingException {
|
public User createUser(@NotNull User user, boolean emailConfirmEnabled, boolean welcomeEmail) throws WiseMappingException {
|
||||||
final UUID uuid = UUID.randomUUID();
|
final UUID uuid = UUID.randomUUID();
|
||||||
user.setCreationDate(Calendar.getInstance());
|
user.setCreationDate(Calendar.getInstance());
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
package com.wisemapping.webmvc;
|
package com.wisemapping.webmvc;
|
||||||
|
|
||||||
|
|
||||||
|
import com.wisemapping.model.AuthenticationSchema;
|
||||||
|
import com.wisemapping.service.InvalidAuthSchemaException;
|
||||||
import com.wisemapping.validator.Messages;
|
import com.wisemapping.validator.Messages;
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
@ -72,9 +74,8 @@ public class UsersController {
|
|||||||
userService.resetPassword(email);
|
userService.resetPassword(email);
|
||||||
result = new ModelAndView("forgotPasswordSuccess");
|
result = new ModelAndView("forgotPasswordSuccess");
|
||||||
|
|
||||||
} catch (InvalidUserEmailException e) {
|
} catch (InvalidUserEmailException|InvalidAuthSchemaException e) {
|
||||||
result = new ModelAndView("forgotPasswordError");
|
result = new ModelAndView("forgotPasswordError");
|
||||||
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -110,6 +111,7 @@ public class UsersController {
|
|||||||
user.setPassword(userBean.getPassword());
|
user.setPassword(userBean.getPassword());
|
||||||
|
|
||||||
boolean confirmRegistrationByEmail = false;
|
boolean confirmRegistrationByEmail = false;
|
||||||
|
user.setAuthenticationSchema(AuthenticationSchema.DATABASE);
|
||||||
userService.createUser(user, confirmRegistrationByEmail,true);
|
userService.createUser(user, confirmRegistrationByEmail,true);
|
||||||
|
|
||||||
// Forward to the success view ...
|
// Forward to the success view ...
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
<property name="activationDate" column="activation_date"/>
|
<property name="activationDate" column="activation_date"/>
|
||||||
<property name="activationCode" column="activation_code"/>
|
<property name="activationCode" column="activation_code"/>
|
||||||
<property name="allowSendEmail" column="allow_send_email"/>
|
<property name="allowSendEmail" column="allow_send_email"/>
|
||||||
|
<property name="autheticationCode" column="auth_schema"/>
|
||||||
|
|
||||||
<property name="locale"/>
|
<property name="locale"/>
|
||||||
<set name="tags" table="TAG">
|
<set name="tags" table="TAG">
|
||||||
<key column="user_id"/>
|
<key column="user_id"/>
|
||||||
|
@ -246,7 +246,7 @@ LICENSE=License
|
|||||||
WELCOME_TO_WISEMAPPING=Welcome to WiseMapping
|
WELCOME_TO_WISEMAPPING=Welcome to WiseMapping
|
||||||
WELCOME_DETAILS=WiseMapping will enable you to create and read your mind maps everywhere. With WiseMapping you can: <ul><li>Embed mind map it in web pages and blogs</li><li>Link mind map and documents</li><li>Share your maps with friend and colleagues</li><li>Export your maps SVG,PNG,JPG and FreeMind</li></ul>.
|
WELCOME_DETAILS=WiseMapping will enable you to create and read your mind maps everywhere. With WiseMapping you can: <ul><li>Embed mind map it in web pages and blogs</li><li>Link mind map and documents</li><li>Share your maps with friend and colleagues</li><li>Export your maps SVG,PNG,JPG and FreeMind</li></ul>.
|
||||||
OPEN_ID_LOGIN=Open Id Login
|
OPEN_ID_LOGIN=Open Id Login
|
||||||
LOGING_OPENID_DETAILS=Why OpenID? It's a single username and password that allows you to log in to any OpenID-enabled site. It works on thousands of websites.ItÕs an open standard.</br>Do you already have an account on one of these sites? Click the logo to <b>log in</b> with it here:
|
LOGING_OPENID_DETAILS=Why OpenID? It's a single username and password that allows you to log in to any OpenID-enabled site. It works on thousands of websites.ItÕs an open standard. Do you already have an account on one of these sites? Click the logo to <b>log in</b> with it here:
|
||||||
DIRECT_LINK_EXPLANATION=Copy and paste the link below to share your map with colleagues
|
DIRECT_LINK_EXPLANATION=Copy and paste the link below to share your map with colleagues
|
||||||
TEMPORAL_PASSWORD_SENT=Your temporal password has been sent
|
TEMPORAL_PASSWORD_SENT=Your temporal password has been sent
|
||||||
TEMPORAL_PASSWORD_SENT_DETAILS=We've sent you an email that will allow you to reset your password. Please check your email now.
|
TEMPORAL_PASSWORD_SENT_DETAILS=We've sent you an email that will allow you to reset your password. Please check your email now.
|
||||||
|
@ -3,15 +3,15 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<c:if test="${requestScope['security.type']=='db'}">
|
<c:if test="${principal.databaseSchema}">
|
||||||
<li class="active"><a href="#changeUserPanel" data-toggle="pill"><spring:message code="GENERAL"/></a></li>
|
<li class="active"><a href="#changeUserPanel" data-toggle="pill"><spring:message code="GENERAL"/></a></li>
|
||||||
<li><a href="#changePasswordPanel" data-toggle="pill"><spring:message code="SECURITY"/></a></li>
|
<li><a href="#changePasswordPanel" data-toggle="pill"><spring:message code="SECURITY"/></a></li>
|
||||||
</c:if>
|
</c:if>
|
||||||
<li><a href="#languagePanel" data-toggle="pill"><spring:message code="LANGUAGE"/></a></li>
|
<li><a href="#languagePanel" data-toggle="pill"><spring:message code="LANGUAGE"/></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane fade active in" id="changeUserPanel">
|
<div class="tab-pane fade ${principal.databaseSchema?'active in':''}" id="changeUserPanel">
|
||||||
<div id="changeInfoMsg" class="alert">
|
<div id="changeInfoMsg" class="alert">
|
||||||
</div>
|
</div>
|
||||||
<form action="#" method="POST" id="changeUserForm">
|
<form action="#" method="POST" id="changeUserForm">
|
||||||
@ -48,7 +48,7 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane fade" id="languagePanel">
|
<div class="tab-pane fade ${principal.databaseSchema?'':'active in'}" id="languagePanel">
|
||||||
<div id="languageMsg" class="alert">
|
<div id="languageMsg" class="alert">
|
||||||
</div>
|
</div>
|
||||||
<form action="#" method="POST" id="languageForm">
|
<form action="#" method="POST" id="languageForm">
|
||||||
@ -99,16 +99,16 @@
|
|||||||
function postChange(url, postBody, msgContainerId, successMsg) {
|
function postChange(url, postBody, msgContainerId, successMsg) {
|
||||||
// Change success message ...
|
// Change success message ...
|
||||||
jQuery.ajax(url, {
|
jQuery.ajax(url, {
|
||||||
async:false,
|
async: false,
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:postBody,
|
data: postBody,
|
||||||
type:'PUT',
|
type: 'PUT',
|
||||||
contentType:"text/plain; charset=utf-8",
|
contentType: "text/plain; charset=utf-8",
|
||||||
success:function (data, textStatus, jqXHR) {
|
success: function (data, textStatus, jqXHR) {
|
||||||
$('#' + msgContainerId).removeClass('alert-error').addClass('alert-info').show();
|
$('#' + msgContainerId).removeClass('alert-error').addClass('alert-info').show();
|
||||||
$('#' + msgContainerId).text(successMsg);
|
$('#' + msgContainerId).text(successMsg);
|
||||||
},
|
},
|
||||||
error:function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
$('#' + msgContainerId).removeClass('alert-info').addClass('alert-error').show();
|
$('#' + msgContainerId).removeClass('alert-info').addClass('alert-error').show();
|
||||||
$('#' + msgContainerId).text(textStatus);
|
$('#' + msgContainerId).text(textStatus);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user