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;
|
||||
|
||||
public enum AuthenticationSchema {
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum AuthenticationType {
|
||||
DATABASE('D'),
|
||||
LDAP('L'),
|
||||
OPENID('O');
|
||||
private final char schemaCode;
|
||||
|
||||
AuthenticationSchema(char schemaCode) {
|
||||
AuthenticationType(char schemaCode) {
|
||||
this.schemaCode = schemaCode;
|
||||
}
|
||||
|
||||
@ -14,10 +17,11 @@ public enum AuthenticationSchema {
|
||||
return schemaCode;
|
||||
}
|
||||
|
||||
public static AuthenticationSchema valueOf(char code) {
|
||||
AuthenticationSchema result = null;
|
||||
AuthenticationSchema[] values = AuthenticationSchema.values();
|
||||
for (AuthenticationSchema value : values) {
|
||||
@NotNull
|
||||
public static AuthenticationType valueOf(char code) {
|
||||
AuthenticationType result = null;
|
||||
AuthenticationType[] values = AuthenticationType.values();
|
||||
for (AuthenticationType value : values) {
|
||||
if (value.getCode() == code) {
|
||||
result = value;
|
||||
break;
|
@ -38,7 +38,10 @@ public class User
|
||||
private Set<String> tags = new HashSet<String>();
|
||||
private boolean allowSendEmail = false;
|
||||
private String locale;
|
||||
private AuthenticationSchema authenticationSchema;
|
||||
private AuthenticationType authenticationType;
|
||||
|
||||
|
||||
private String authenticatorUri;
|
||||
|
||||
public User() {
|
||||
}
|
||||
@ -116,24 +119,32 @@ public class User
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public char getAutheticationCode() {
|
||||
return this.authenticationSchema != null ? this.authenticationSchema.getCode() : null;
|
||||
public char getAutheticationTypeCode() {
|
||||
return this.authenticationType != null ? this.authenticationType.getCode() : null;
|
||||
}
|
||||
|
||||
public void setAutheticationCode(char code) {
|
||||
this.authenticationSchema = AuthenticationSchema.valueOf(code);
|
||||
public void setAutheticationTypeCode(char code) {
|
||||
this.authenticationType = AuthenticationType.valueOf(code);
|
||||
}
|
||||
|
||||
public AuthenticationSchema getAuthenticationSchema() {
|
||||
return authenticationSchema;
|
||||
public AuthenticationType getAuthenticationType() {
|
||||
return authenticationType;
|
||||
}
|
||||
|
||||
public void setAuthenticationSchema(@NotNull AuthenticationSchema authenticationSchema) {
|
||||
this.authenticationSchema = authenticationSchema;
|
||||
public void setAuthenticationType(@NotNull AuthenticationType authenticationType) {
|
||||
this.authenticationType = authenticationType;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.AuthenticationSchema;
|
||||
import com.wisemapping.model.AuthenticationType;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestUser;
|
||||
import com.wisemapping.service.UserService;
|
||||
@ -85,7 +85,7 @@ public class AdminController extends BaseController {
|
||||
}
|
||||
|
||||
// Finally create the user ...
|
||||
delegated.setAuthenticationSchema(AuthenticationSchema.DATABASE);
|
||||
delegated.setAuthenticationType(AuthenticationType.DATABASE);
|
||||
userService.createUser(delegated, false, true);
|
||||
response.setHeader("Location", "/service/admin/users/" + user.getId());
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ package com.wisemapping.security;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.AuthenticationSchema;
|
||||
import com.wisemapping.model.AuthenticationType;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.service.UserService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -60,10 +60,15 @@ public class UserDetailsService
|
||||
|
||||
final User result;
|
||||
if (dbUser != null) {
|
||||
if (!token.getIdentityUrl().equals(dbUser.getAuthenticatorUri())) {
|
||||
throw new IllegalStateException("Identity url for this user can not change:" + token.getIdentityUrl());
|
||||
}
|
||||
result = dbUser;
|
||||
} else {
|
||||
try {
|
||||
tUser.setAuthenticationSchema(AuthenticationSchema.OPENID);
|
||||
tUser.setAuthenticationType(AuthenticationType.OPENID);
|
||||
tUser.setAuthenticatorUri(token.getIdentityUrl());
|
||||
|
||||
result = userService.createUser(tUser, false, false);
|
||||
} catch (WiseMappingException e) {
|
||||
throw new IllegalStateException(e);
|
||||
|
@ -2,7 +2,7 @@ package com.wisemapping.security.ldap;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.AuthenticationSchema;
|
||||
import com.wisemapping.model.AuthenticationType;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.security.UserDetails;
|
||||
import com.wisemapping.service.UserService;
|
||||
@ -65,7 +65,7 @@ public class LdapUserDetailsContextMapper implements UserDetailsContextMapper {
|
||||
user.setActivationDate(now);
|
||||
|
||||
try {
|
||||
user.setAuthenticationSchema(AuthenticationSchema.LDAP);
|
||||
user.setAuthenticationType(AuthenticationType.LDAP);
|
||||
user = userService.createUser(user, false, false);
|
||||
} catch (WiseMappingException e) {
|
||||
throw new IllegalStateException(e);
|
||||
|
@ -19,7 +19,6 @@
|
||||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.dao.UserManager;
|
||||
import com.wisemapping.exceptions.ClientException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.mail.NotificationService;
|
||||
import com.wisemapping.model.*;
|
||||
@ -61,8 +60,8 @@ public class UserServiceImpl
|
||||
final User user = userManager.getUserBy(email);
|
||||
if (user != null) {
|
||||
|
||||
if (user.getAuthenticationSchema() != AuthenticationSchema.DATABASE) {
|
||||
throw new InvalidAuthSchemaException("Could not change password for " + user.getAuthenticationSchema().getCode());
|
||||
if (user.getAuthenticationType() != AuthenticationType.DATABASE) {
|
||||
throw new InvalidAuthSchemaException("Could not change password for " + user.getAuthenticationType().getCode());
|
||||
}
|
||||
|
||||
// Generate a random password ...
|
||||
|
@ -45,14 +45,14 @@ public class LoginController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "loginOpenId", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "loginopenid", method = RequestMethod.GET)
|
||||
protected ModelAndView showLoginOpenIdPage() {
|
||||
final User user = Utils.getUser(false);
|
||||
ModelAndView result;
|
||||
if (user != null) {
|
||||
result = new ModelAndView("forward:/c/maps/");
|
||||
} else {
|
||||
result = new ModelAndView("loginOpenId");
|
||||
result = new ModelAndView("loginopenid");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
package com.wisemapping.webmvc;
|
||||
|
||||
|
||||
import com.wisemapping.model.AuthenticationSchema;
|
||||
import com.wisemapping.model.AuthenticationType;
|
||||
import com.wisemapping.service.InvalidAuthSchemaException;
|
||||
import com.wisemapping.validator.Messages;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
@ -111,7 +111,7 @@ public class UsersController {
|
||||
user.setPassword(userBean.getPassword());
|
||||
|
||||
boolean confirmRegistrationByEmail = false;
|
||||
user.setAuthenticationSchema(AuthenticationSchema.DATABASE);
|
||||
user.setAuthenticationType(AuthenticationType.DATABASE);
|
||||
userService.createUser(user, confirmRegistrationByEmail,true);
|
||||
|
||||
// Forward to the success view ...
|
||||
|
@ -27,7 +27,8 @@
|
||||
<property name="activationDate" column="activation_date"/>
|
||||
<property name="activationCode" column="activation_code"/>
|
||||
<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"/>
|
||||
<set name="tags" table="TAG">
|
||||
|
@ -246,7 +246,8 @@ LICENSE=License
|
||||
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>.
|
||||
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
|
||||
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.
|
||||
|
@ -75,7 +75,7 @@
|
||||
<put-attribute name="removeSignin" value="true"/>
|
||||
</definition>
|
||||
|
||||
<definition name="loginOpenId" extends="pageTemplate">
|
||||
<definition name="loginopenid" extends="pageTemplate">
|
||||
<put-attribute name="title" value="LOGIN"/>
|
||||
<put-attribute name="body" value="/jsp/loginOpenId.jsp"/>
|
||||
<put-attribute name="removeSignin" value="true"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<sec:http pattern="/favicon.ico" 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/resetpassword" 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: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: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"/>
|
||||
|
@ -75,6 +75,10 @@
|
||||
<spring:message code="JOIN_NOW"/>
|
||||
</a>
|
||||
</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>
|
||||
|
||||
|
@ -2,6 +2,17 @@
|
||||
<%@ include file="/jsp/init.jsp" %>
|
||||
|
||||
<%--@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" language="javascript">
|
||||
@ -11,7 +22,7 @@
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<div class="row-fluid">
|
||||
<div class="row-fluid" style="padding: 10px 0px">
|
||||
<h1><spring:message code="OPEN_ID_LOGIN"/></h1>
|
||||
<spring:message code="LOGING_OPENID_DETAILS"/>
|
||||
</div>
|
||||
@ -38,4 +49,8 @@
|
||||
</form>
|
||||
<!-- /Simple OpenID Selector -->
|
||||
</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 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>
|
||||
<body>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user