1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-27 00:22:33 +00:00

Initial commit

This commit is contained in:
jendib
2013-07-27 18:33:20 +02:00
parent 41cb6dd9ae
commit 9b74bd8194
156 changed files with 72879 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
package com.sismics.security;
import java.util.Locale;
import org.joda.time.DateTimeZone;
/**
* Anonymous principal.
*
* @author jtremeaux
*/
public class AnonymousPrincipal implements IPrincipal {
public static final String ANONYMOUS = "anonymous";
/**
* User locale.
*/
private Locale locale;
/**
* User timezone.
*/
private DateTimeZone dateTimeZone;
/**
* Constructor of AnonymousPrincipal.
*/
public AnonymousPrincipal() {
// NOP
}
@Override
public String getId() {
return null;
}
@Override
public String getName() {
return ANONYMOUS;
}
@Override
public boolean isAnonymous() {
return true;
}
@Override
public Locale getLocale() {
return locale;
}
/**
* Setter of locale.
*
* @param locale locale
*/
public void setLocale(Locale locale) {
this.locale = locale;
}
@Override
public DateTimeZone getDateTimeZone() {
return dateTimeZone;
}
@Override
public String getEmail() {
return null;
}
/**
* Setter of dateTimeZone.
*
* @param dateTimeZone dateTimeZone
*/
public void setDateTimeZone(DateTimeZone dateTimeZone) {
this.dateTimeZone = dateTimeZone;
}
}

View File

@@ -0,0 +1,48 @@
package com.sismics.security;
import java.security.Principal;
import java.util.Locale;
import org.joda.time.DateTimeZone;
/**
* Interface of principals.
*
* @author jtremeaux
*/
public interface IPrincipal extends Principal {
/**
* Checks if the principal is anonymous.
*
* @return True if the principal is anonymous.
*/
boolean isAnonymous();
/**
* Returns the ID of the connected user, or null if the user is anonymous
*
* @return ID of the connected user
*/
public String getId();
/**
* Returns the locale of the principal.
*
* @return Locale of the principal
*/
public Locale getLocale();
/**
* Returns the timezone of the principal.
*
* @return Timezone of the principal
*/
public DateTimeZone getDateTimeZone();
/**
* Returns the email of the principal.
*
* @return Email of the principal
*/
public String getEmail();
}

View File

@@ -0,0 +1,148 @@
package com.sismics.security;
import java.util.Locale;
import java.util.Set;
import org.joda.time.DateTimeZone;
/**
* Authenticated users principal.
*
* @author jtremeaux
*/
public class UserPrincipal implements IPrincipal {
/**
* ID of the user.
*/
private String id;
/**
* Username of the user.
*/
private String name;
/**
* Locale of the principal.
*/
private Locale locale;
/**
* Timezone of the principal.
*/
private DateTimeZone dateTimeZone;
/**
* Email of the principal.
*/
private String email;
/**
* User base functions.
*/
private Set<String> baseFunctionSet;
/**
* Constructor of UserPrincipal.
*
* @param id ID of the user
* @param name Usrename of the user
*/
public UserPrincipal(String id, String name) {
this.id = id;
this.name = name;
}
@Override
public boolean isAnonymous() {
return false;
}
@Override
public String getId() {
return id;
}
/**
* Setter of id.
*
* @param id id
*/
public void setId(String id) {
this.id = id;
}
@Override
public String getName() {
return name;
}
/**
* Setter of name.
*
* @param name name
*/
public void setName(String name) {
this.name = name;
}
@Override
public Locale getLocale() {
return locale;
}
/**
* Setter of locale.
*
* @param locale locale
*/
public void setLocale(Locale locale) {
this.locale = locale;
}
@Override
public DateTimeZone getDateTimeZone() {
return dateTimeZone;
}
/**
* Setter of dateTimeZone.
*
* @param dateTimeZone dateTimeZone
*/
public void setDateTimeZone(DateTimeZone dateTimeZone) {
this.dateTimeZone = dateTimeZone;
}
@Override
public String getEmail() {
return email;
}
/**
* Setter of email.
*
* @param email email
*/
public void setEmail(String email) {
this.email = email;
}
/**
* Getter of baseFunctionSet.
*
* @return baseFunctionSet
*/
public Set<String> getBaseFunctionSet() {
return baseFunctionSet;
}
/**
* Setter of baseFunctionSet.
*
* @param baseFunctionSet baseFunctionSet
*/
public void setBaseFunctionSet(Set<String> baseFunctionSet) {
this.baseFunctionSet = baseFunctionSet;
}
}