mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Finish OpenId implementation.
This commit is contained in:
parent
94356a5773
commit
9b21c77485
@ -1,12 +1,15 @@
|
|||||||
package com.wisemapping.model;
|
package com.wisemapping.model;
|
||||||
|
|
||||||
public enum AuthenticationSchema {
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public enum AuthenticationType {
|
||||||
DATABASE('D'),
|
DATABASE('D'),
|
||||||
LDAP('L'),
|
LDAP('L'),
|
||||||
OPENID('O');
|
OPENID('O');
|
||||||
private final char schemaCode;
|
private final char schemaCode;
|
||||||
|
|
||||||
AuthenticationSchema(char schemaCode) {
|
AuthenticationType(char schemaCode) {
|
||||||
this.schemaCode = schemaCode;
|
this.schemaCode = schemaCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,10 +17,11 @@ public enum AuthenticationSchema {
|
|||||||
return schemaCode;
|
return schemaCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AuthenticationSchema valueOf(char code) {
|
@NotNull
|
||||||
AuthenticationSchema result = null;
|
public static AuthenticationType valueOf(char code) {
|
||||||
AuthenticationSchema[] values = AuthenticationSchema.values();
|
AuthenticationType result = null;
|
||||||
for (AuthenticationSchema value : values) {
|
AuthenticationType[] values = AuthenticationType.values();
|
||||||
|
for (AuthenticationType value : values) {
|
||||||
if (value.getCode() == code) {
|
if (value.getCode() == code) {
|
||||||
result = value;
|
result = value;
|
||||||
break;
|
break;
|
@ -38,7 +38,10 @@ public class User
|
|||||||
private Set<String> tags = new HashSet<String>();
|
private Set<String> tags = new HashSet<String>();
|
||||||
private boolean allowSendEmail = false;
|
private boolean allowSendEmail = false;
|
||||||
private String locale;
|
private String locale;
|
||||||
private AuthenticationSchema authenticationSchema;
|
private AuthenticationType authenticationType;
|
||||||
|
|
||||||
|
|
||||||
|
private String authenticatorUri;
|
||||||
|
|
||||||
public User() {
|
public User() {
|
||||||
}
|
}
|
||||||
@ -116,24 +119,32 @@ public class User
|
|||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public char getAutheticationCode() {
|
public char getAutheticationTypeCode() {
|
||||||
return this.authenticationSchema != null ? this.authenticationSchema.getCode() : null;
|
return this.authenticationType != null ? this.authenticationType.getCode() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAutheticationCode(char code) {
|
public void setAutheticationTypeCode(char code) {
|
||||||
this.authenticationSchema = AuthenticationSchema.valueOf(code);
|
this.authenticationType = AuthenticationType.valueOf(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthenticationSchema getAuthenticationSchema() {
|
public AuthenticationType getAuthenticationType() {
|
||||||
return authenticationSchema;
|
return authenticationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthenticationSchema(@NotNull AuthenticationSchema authenticationSchema) {
|
public void setAuthenticationType(@NotNull AuthenticationType authenticationType) {
|
||||||
this.authenticationSchema = authenticationSchema;
|
this.authenticationType = authenticationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDatabaseSchema(){
|
public boolean isDatabaseSchema(){
|
||||||
return this.authenticationSchema==AuthenticationSchema.DATABASE;
|
return this.authenticationType == AuthenticationType.DATABASE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthenticatorUri() {
|
||||||
|
return authenticatorUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthenticatorUri(String authenticatorUri) {
|
||||||
|
this.authenticatorUri = authenticatorUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package com.wisemapping.rest;
|
package com.wisemapping.rest;
|
||||||
|
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
import com.wisemapping.model.AuthenticationSchema;
|
import com.wisemapping.model.AuthenticationType;
|
||||||
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,7 @@ public class AdminController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Finally create the user ...
|
// Finally create the user ...
|
||||||
delegated.setAuthenticationSchema(AuthenticationSchema.DATABASE);
|
delegated.setAuthenticationType(AuthenticationType.DATABASE);
|
||||||
userService.createUser(delegated, false, true);
|
userService.createUser(delegated, false, true);
|
||||||
response.setHeader("Location", "/service/admin/users/" + user.getId());
|
response.setHeader("Location", "/service/admin/users/" + user.getId());
|
||||||
}
|
}
|
||||||
|
@ -20,7 +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.AuthenticationType;
|
||||||
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;
|
||||||
@ -60,10 +60,15 @@ public class UserDetailsService
|
|||||||
|
|
||||||
final User result;
|
final User result;
|
||||||
if (dbUser != null) {
|
if (dbUser != null) {
|
||||||
|
if (!token.getIdentityUrl().equals(dbUser.getAuthenticatorUri())) {
|
||||||
|
throw new IllegalStateException("Identity url for this user can not change:" + token.getIdentityUrl());
|
||||||
|
}
|
||||||
result = dbUser;
|
result = dbUser;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
tUser.setAuthenticationSchema(AuthenticationSchema.OPENID);
|
tUser.setAuthenticationType(AuthenticationType.OPENID);
|
||||||
|
tUser.setAuthenticatorUri(token.getIdentityUrl());
|
||||||
|
|
||||||
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,7 +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.AuthenticationType;
|
||||||
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;
|
||||||
@ -65,7 +65,7 @@ public class LdapUserDetailsContextMapper implements UserDetailsContextMapper {
|
|||||||
user.setActivationDate(now);
|
user.setActivationDate(now);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
user.setAuthenticationSchema(AuthenticationSchema.LDAP);
|
user.setAuthenticationType(AuthenticationType.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);
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
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.*;
|
import com.wisemapping.model.*;
|
||||||
@ -61,8 +60,8 @@ public class UserServiceImpl
|
|||||||
final User user = userManager.getUserBy(email);
|
final User user = userManager.getUserBy(email);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
|
||||||
if (user.getAuthenticationSchema() != AuthenticationSchema.DATABASE) {
|
if (user.getAuthenticationType() != AuthenticationType.DATABASE) {
|
||||||
throw new InvalidAuthSchemaException("Could not change password for " + user.getAuthenticationSchema().getCode());
|
throw new InvalidAuthSchemaException("Could not change password for " + user.getAuthenticationType().getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a random password ...
|
// Generate a random password ...
|
||||||
|
@ -45,14 +45,14 @@ public class LoginController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "loginOpenId", method = RequestMethod.GET)
|
@RequestMapping(value = "loginopenid", method = RequestMethod.GET)
|
||||||
protected ModelAndView showLoginOpenIdPage() {
|
protected ModelAndView showLoginOpenIdPage() {
|
||||||
final User user = Utils.getUser(false);
|
final User user = Utils.getUser(false);
|
||||||
ModelAndView result;
|
ModelAndView result;
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
result = new ModelAndView("forward:/c/maps/");
|
result = new ModelAndView("forward:/c/maps/");
|
||||||
} else {
|
} else {
|
||||||
result = new ModelAndView("loginOpenId");
|
result = new ModelAndView("loginopenid");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package com.wisemapping.webmvc;
|
package com.wisemapping.webmvc;
|
||||||
|
|
||||||
|
|
||||||
import com.wisemapping.model.AuthenticationSchema;
|
import com.wisemapping.model.AuthenticationType;
|
||||||
import com.wisemapping.service.InvalidAuthSchemaException;
|
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;
|
||||||
@ -111,7 +111,7 @@ public class UsersController {
|
|||||||
user.setPassword(userBean.getPassword());
|
user.setPassword(userBean.getPassword());
|
||||||
|
|
||||||
boolean confirmRegistrationByEmail = false;
|
boolean confirmRegistrationByEmail = false;
|
||||||
user.setAuthenticationSchema(AuthenticationSchema.DATABASE);
|
user.setAuthenticationType(AuthenticationType.DATABASE);
|
||||||
userService.createUser(user, confirmRegistrationByEmail,true);
|
userService.createUser(user, confirmRegistrationByEmail,true);
|
||||||
|
|
||||||
// Forward to the success view ...
|
// Forward to the success view ...
|
||||||
|
@ -27,7 +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="autheticationTypeCode" column="authentication_type"/>
|
||||||
|
<property name="authenticatorUri" column="authenticator_uri"/>
|
||||||
|
|
||||||
<property name="locale"/>
|
<property name="locale"/>
|
||||||
<set name="tags" table="TAG">
|
<set name="tags" table="TAG">
|
||||||
|
@ -246,7 +246,8 @@ 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. 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=Do you already have an account on one of these sites?. Click the logo to log in with it here:
|
||||||
|
WHY_OPENID=<b>Why OpenID ?</b></br> It's a single username and password that allows you to log in to any OpenID-enabled site. It works on thousands of websites.</br>It's an open standard. </br><a href="http://openid.net/what/">learn more</a>
|
||||||
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.
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
<put-attribute name="removeSignin" value="true"/>
|
<put-attribute name="removeSignin" value="true"/>
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
<definition name="loginOpenId" extends="pageTemplate">
|
<definition name="loginopenid" extends="pageTemplate">
|
||||||
<put-attribute name="title" value="LOGIN"/>
|
<put-attribute name="title" value="LOGIN"/>
|
||||||
<put-attribute name="body" value="/jsp/loginOpenId.jsp"/>
|
<put-attribute name="body" value="/jsp/loginOpenId.jsp"/>
|
||||||
<put-attribute name="removeSignin" value="true"/>
|
<put-attribute name="removeSignin" value="true"/>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<sec:http pattern="/favicon.ico" security="none"/>
|
<sec:http pattern="/favicon.ico" security="none"/>
|
||||||
|
|
||||||
<sec:http pattern="/c/login" security="none"/>
|
<sec:http pattern="/c/login" security="none"/>
|
||||||
<sec:http pattern="/c/loginOpenId" security="none"/>
|
<sec:http pattern="/c/loginopenid" security="none"/>
|
||||||
<sec:http pattern="/c/user/registration" security="none"/>
|
<sec:http pattern="/c/user/registration" security="none"/>
|
||||||
<sec:http pattern="/c/user/resetpassword" security="none"/>
|
<sec:http pattern="/c/user/resetpassword" security="none"/>
|
||||||
<sec:http pattern="/c/home" security="none"/>
|
<sec:http pattern="/c/home" security="none"/>
|
||||||
@ -66,6 +66,11 @@
|
|||||||
<sec:openid-attribute name="fullname" type="http://axschema.org/namePerson" required="true"/>
|
<sec:openid-attribute name="fullname" type="http://axschema.org/namePerson" required="true"/>
|
||||||
</sec:attribute-exchange>
|
</sec:attribute-exchange>
|
||||||
|
|
||||||
|
<sec:attribute-exchange identifier-match=".*yahoo.com.*">
|
||||||
|
<sec:openid-attribute name="email" type="http://axschema.org/contact/email" required="true"/>
|
||||||
|
<sec:openid-attribute name="fullname" type="http://axschema.org/namePerson" required="true"/>
|
||||||
|
</sec:attribute-exchange>
|
||||||
|
|
||||||
<sec:attribute-exchange identifier-match=".*myopenid.com.*">
|
<sec:attribute-exchange identifier-match=".*myopenid.com.*">
|
||||||
<sec:openid-attribute name="email" type="http://schema.openid.net/contact/email" required="true"/>
|
<sec:openid-attribute name="email" type="http://schema.openid.net/contact/email" required="true"/>
|
||||||
<sec:openid-attribute name="fullname" type="http://schema.openid.net/namePerson" required="true"/>
|
<sec:openid-attribute name="fullname" type="http://schema.openid.net/namePerson" required="true"/>
|
||||||
|
@ -75,6 +75,10 @@
|
|||||||
<spring:message code="JOIN_NOW"/>
|
<spring:message code="JOIN_NOW"/>
|
||||||
</a>
|
</a>
|
||||||
</c:if>
|
</c:if>
|
||||||
|
<p>
|
||||||
|
Do you already have an account on <b>GMail, Yahoo, AOL or other OpenId site</b> ?. Sign in in with it <a href="/c/loginopenid"><b>here</b></a>.
|
||||||
|
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -2,6 +2,17 @@
|
|||||||
<%@ include file="/jsp/init.jsp" %>
|
<%@ include file="/jsp/init.jsp" %>
|
||||||
|
|
||||||
<%--@elvariable id="isHsql" type="boolean"--%>
|
<%--@elvariable id="isHsql" type="boolean"--%>
|
||||||
|
<!-- Simple OpenID Selector -->
|
||||||
|
<link type="text/css" rel="stylesheet" href="css/openid.css"/>
|
||||||
|
<script type="text/javascript" language="javascript" src="js/jquery-1.7.2.min.js"></script>
|
||||||
|
<script type="text/javascript" language="javascript" src="js/openid-jquery.js"></script>
|
||||||
|
<script type="text/javascript" language="javascript" src="js/openid-en.js"></script>
|
||||||
|
<!-- /Simple OpenID Selector -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
openid.init('openid_identifier');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
|
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
|
||||||
<script type="text/javascript" language="javascript">
|
<script type="text/javascript" language="javascript">
|
||||||
@ -11,7 +22,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid" style="padding: 10px 0px">
|
||||||
<h1><spring:message code="OPEN_ID_LOGIN"/></h1>
|
<h1><spring:message code="OPEN_ID_LOGIN"/></h1>
|
||||||
<spring:message code="LOGING_OPENID_DETAILS"/>
|
<spring:message code="LOGING_OPENID_DETAILS"/>
|
||||||
</div>
|
</div>
|
||||||
@ -38,4 +49,8 @@
|
|||||||
</form>
|
</form>
|
||||||
<!-- /Simple OpenID Selector -->
|
<!-- /Simple OpenID Selector -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="span4" style="background-color: #FFEFC6;padding: 10px">
|
||||||
|
<spring:message code="WHY_OPENID"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@ -42,18 +42,6 @@
|
|||||||
|
|
||||||
<script type="text/javascript" language="javascript" src="bootstrap/js/bootstrap.js"></script>
|
<script type="text/javascript" language="javascript" src="bootstrap/js/bootstrap.js"></script>
|
||||||
<script src="js/less.js" type="text/javascript"></script>
|
<script src="js/less.js" type="text/javascript"></script>
|
||||||
|
|
||||||
<!-- Simple OpenID Selector -->
|
|
||||||
<link type="text/css" rel="stylesheet" href="css/openid.css"/>
|
|
||||||
<script type="text/javascript" language="javascript" src="js/jquery-1.7.2.min.js"></script>
|
|
||||||
<script type="text/javascript" language="javascript" src="js/openid-jquery.js"></script>
|
|
||||||
<script type="text/javascript" language="javascript" src="js/openid-en.js"></script>
|
|
||||||
<!-- /Simple OpenID Selector -->
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(document).ready(function() {
|
|
||||||
openid.init('openid_identifier');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user