Project: * Clean-up (Eclipse cruft, unused files, etc...) * Git-specific changes * Maven POMs clean-up and changes for the build system * Version set to 1.0.0-0 in the development branches * Maven plug-ins updated to latest versions * Very partial dev. documentation added
This commit is contained in:
parent
c74e30d5ba
commit
0665a760de
1439 changed files with 1020 additions and 1649 deletions
legacyworlds-server-beans-user/src/main/java/com/deepclone/lw/beans/user
ObjectNameValidatorBean.java
abst
AutowiredCommandDelegate.javaAutowiredSubTypeDelegate.javaSessionCommandDelegate.javaSessionCommandHandler.javaSessionCommandWiringBean.javaSessionSubTypeDelegate.javaSessionSubTypeWiringBean.javaStatefulSessionTypeDefiner.java
admin
AdminSessionDefinerBean.javaAdminSessionSubType.java
common
AdminOperation.javaCommonCommandsBean.javaCreateAuthChallengeCommandDelegateBean.javaNoOperationCommandDelegateBean.javaSetPasswordCommandDelegateBean.java
main
AdminCommandsBean.javaAdminOverviewCommandDelegateBean.java
bans
BansSummaryCommandDelegateBean.javaConfirmBanCommandDelegateBean.javaLiftBanCommandDelegateBean.javaListBansCommandDelegateBean.javaRejectBanCommandDelegateBean.javaRequestBanCommandDelegateBean.java
bt
BugsSummaryCommandDelegateBean.javaGetSnapshotCommandDelegateBean.javaListBugsCommandDelegateBean.javaMergeReportsCommandDelegateBean.javaModerateCommentCommandDelegateBean.javaPostCommentCommandDelegateBean.javaReportBugCommandDelegateBean.javaReportStatusCommandDelegateBean.javaReportVisibilityCommandDelegateBean.javaValidateReportCommandDelegateBean.javaViewBugCommandDelegateBean.java
cnst
i18n
ChangeLanguageCommandDelegateBean.javaGetLanguageCommandDelegateBean.javaSetStringCommandDelegateBean.javaViewLanguagesCommandDelegateBean.java
logs
mntm
EnableMaintenanceCommandDelegateBean.javaEndMaintenanceCommandDelegateBean.javaExtendMaintenanceCommandDelegateBean.javaMaintenanceStatusCommandDelegateBean.java
msgs
ComposeMessageCommandDelegateBean.javaGetMessagesCommandDelegateBean.javaMessageBoxCommandDelegateBean.javaPrepareMessageCommandDelegateBean.javaReadMessageCommandDelegateBean.javaSendSpamCommandDelegateBean.java
names
GetNamesCommandDelegateBean.javaNamesActionCommandDelegateBean.javaNamesSummaryCommandDelegateBean.java
prefs
su
AddAdministratorCommandDelegateBean.javaListAdministratorsCommandDelegateBean.javaResetAdminPasswordCommandDelegateBean.javaSUExistingOperation.javaSetPrivilegesCommandDelegateBean.javaSuperUserOperation.javaViewAdministratorCommandDelegateBean.java
tick
SetTaskStatusCommandDelegateBean.javaTickerStatusCommandDelegateBean.javaToggleTickerCommandDelegateBean.java
users
ext
AccountCreationCommandDelegateBean.javaConfPwdRecoveryCommandDelegateBean.javaExternalSessionDefinerBean.javaLanguageListRequired.javaListLanguagesCommandDelegateBean.javaReqPwdRecoveryCommandDelegateBean.java
player
BanDetailsCommandDelegateBean.javaBannedSubTypeBean.javaDisabledSubTypeBean.javaGameSubTypeBean.javaGetLanguageCommandDelegateBean.javaPlayerCommonCommandsBean.javaPlayerSessionDefinerBean.javaPlayerSessionSubType.javaReactivateCommandDelegateBean.javaValidationCommandDelegateBean.javaValidationSubTypeBean.java
account
CancelQuitCommandDelegateBean.javaCreateAuthChallengeCommandDelegateBean.javaGetAccountCommandDelegateBean.javaQuitGameCommandDelegateBean.javaSetAddressCommandDelegateBean.javaSetLanguageCommandDelegateBean.javaSetPasswordCommandDelegateBean.javaSetPreferencesCommandDelegateBean.javaToggleVacationCommandDelegateBean.javaValidateSetAddressCommandDelegateBean.java
bt
|
@ -0,0 +1,77 @@
|
|||
package com.deepclone.lw.beans.user;
|
||||
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.deepclone.lw.cmd.ObjectNameError;
|
||||
|
||||
|
||||
|
||||
public class ObjectNameValidatorBean
|
||||
{
|
||||
|
||||
private int minLength = 2;
|
||||
private int maxLength = 20;
|
||||
|
||||
private static Pattern fail[] = {
|
||||
Pattern.compile( "\\s\\s+" ) ,
|
||||
Pattern.compile( "[^A-Za-z0-9 _\\'\\!\\:\\,\\-\\.\\*@\\[\\]\\{\\}]" )
|
||||
};
|
||||
|
||||
private static Pattern needed[] = {
|
||||
Pattern.compile( "[A-Za-z]" )
|
||||
};
|
||||
|
||||
|
||||
public void setMinLength( Integer v )
|
||||
{
|
||||
this.minLength = v;
|
||||
}
|
||||
|
||||
|
||||
public void setMaxLength( Integer v )
|
||||
{
|
||||
this.maxLength = v;
|
||||
}
|
||||
|
||||
|
||||
public ObjectNameError validate( String name )
|
||||
{
|
||||
return this.customValidate( name , this.minLength , this.maxLength );
|
||||
}
|
||||
|
||||
|
||||
public ObjectNameError customValidate( String name , int minLength , int maxLength )
|
||||
{
|
||||
if ( "".equals( name.trim( ) ) ) {
|
||||
return ObjectNameError.EMPTY;
|
||||
}
|
||||
|
||||
// No leading or trailing spaces
|
||||
if ( !name.equals( name.trim( ) ) ) {
|
||||
return ObjectNameError.INVALID;
|
||||
}
|
||||
|
||||
// Check length
|
||||
int length = name.length( );
|
||||
if ( length < minLength || length > maxLength ) {
|
||||
return ObjectNameError.INVALID;
|
||||
}
|
||||
|
||||
// Check bad patterns
|
||||
for ( Pattern p : ObjectNameValidatorBean.fail ) {
|
||||
if ( p.matcher( name ).find( ) ) {
|
||||
return ObjectNameError.INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
// Check good patterns
|
||||
for ( Pattern p : ObjectNameValidatorBean.needed ) {
|
||||
if ( !p.matcher( name ).find( ) ) {
|
||||
return ObjectNameError.INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.deepclone.lw.beans.user.abst;
|
||||
|
||||
|
||||
public interface AutowiredCommandDelegate
|
||||
extends SessionCommandDelegate
|
||||
{
|
||||
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( );
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.deepclone.lw.beans.user.abst;
|
||||
|
||||
|
||||
public interface AutowiredSubTypeDelegate
|
||||
extends SessionSubTypeDelegate
|
||||
{
|
||||
|
||||
public Class< ? extends StatefulSessionTypeDefiner > getSessionType( );
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.deepclone.lw.beans.user.abst;
|
||||
|
||||
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public interface SessionCommandDelegate
|
||||
{
|
||||
|
||||
public Class< ? extends Command > getType( );
|
||||
|
||||
|
||||
public CommandResponse execute( ServerSession session , Command command );
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.deepclone.lw.beans.user.abst;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.SessionCommandException;
|
||||
|
||||
|
||||
|
||||
public abstract class SessionCommandHandler
|
||||
{
|
||||
|
||||
private Map< Class< ? extends Command > , SessionCommandDelegate > commands = new HashMap< Class< ? extends Command > , SessionCommandDelegate >( );
|
||||
|
||||
|
||||
public final void registerCommandDelegate( SessionCommandDelegate delegate )
|
||||
{
|
||||
synchronized ( this.commands ) {
|
||||
this.commands.put( delegate.getType( ) , delegate );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected final CommandResponse executeDelegate( ServerSession session , Command command )
|
||||
throws SessionCommandException
|
||||
{
|
||||
SessionCommandDelegate delegate;
|
||||
synchronized ( this.commands ) {
|
||||
delegate = this.commands.get( command.getClass( ) );
|
||||
}
|
||||
if ( delegate == null ) {
|
||||
throw new SessionCommandException( command.getClass( ).getCanonicalName( ) );
|
||||
}
|
||||
return delegate.execute( session , command );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.deepclone.lw.beans.user.abst;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
|
||||
|
||||
public class SessionCommandWiringBean
|
||||
implements BeanPostProcessor , ApplicationContextAware
|
||||
{
|
||||
private final Logger logger = Logger.getLogger( SessionCommandWiringBean.class );
|
||||
private ApplicationContext context;
|
||||
|
||||
|
||||
@Override
|
||||
public void setApplicationContext( ApplicationContext applicationContext )
|
||||
throws BeansException
|
||||
{
|
||||
this.context = applicationContext;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization( Object bean , String beanName )
|
||||
throws BeansException
|
||||
{
|
||||
return bean;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization( Object bean , String beanName )
|
||||
throws BeansException
|
||||
{
|
||||
if ( bean instanceof SessionCommandHandler ) {
|
||||
this.logger.debug( "Wiring command handler " + beanName );
|
||||
this.autowire( (SessionCommandHandler) bean );
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
|
||||
private void autowire( SessionCommandHandler bean )
|
||||
{
|
||||
Class< ? extends SessionCommandHandler > beanType = bean.getClass( );
|
||||
|
||||
Collection< AutowiredCommandDelegate > delegates;
|
||||
delegates = this.context.getBeansOfType( AutowiredCommandDelegate.class ).values( );
|
||||
|
||||
for ( AutowiredCommandDelegate delegate : delegates ) {
|
||||
if ( delegate.getCommandHandler( ) != beanType ) {
|
||||
continue;
|
||||
}
|
||||
this.logger.debug( "Adding delegate from " + delegate.getClass( ) );
|
||||
bean.registerCommandDelegate( delegate );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.deepclone.lw.beans.user.abst;
|
||||
|
||||
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.SessionCommandException;
|
||||
|
||||
|
||||
|
||||
public interface SessionSubTypeDelegate
|
||||
{
|
||||
|
||||
public String getName( );
|
||||
|
||||
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
throws SessionCommandException;
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.deepclone.lw.beans.user.abst;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
|
||||
|
||||
public class SessionSubTypeWiringBean
|
||||
implements BeanPostProcessor , ApplicationContextAware
|
||||
{
|
||||
private final Logger logger = Logger.getLogger( SessionSubTypeWiringBean.class );
|
||||
private ApplicationContext context;
|
||||
|
||||
|
||||
@Override
|
||||
public void setApplicationContext( ApplicationContext applicationContext )
|
||||
throws BeansException
|
||||
{
|
||||
this.context = applicationContext;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization( Object bean , String beanName )
|
||||
throws BeansException
|
||||
{
|
||||
return bean;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization( Object bean , String beanName )
|
||||
throws BeansException
|
||||
{
|
||||
if ( bean instanceof StatefulSessionTypeDefiner ) {
|
||||
this.logger.debug( "Wiring session type definer " + beanName );
|
||||
this.autowire( (StatefulSessionTypeDefiner) bean );
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
|
||||
private void autowire( StatefulSessionTypeDefiner bean )
|
||||
{
|
||||
Class< ? extends StatefulSessionTypeDefiner > beanType = bean.getClass( );
|
||||
|
||||
Collection< AutowiredSubTypeDelegate > delegates;
|
||||
delegates = this.context.getBeansOfType( AutowiredSubTypeDelegate.class ).values( );
|
||||
|
||||
for ( AutowiredSubTypeDelegate delegate : delegates ) {
|
||||
if ( delegate.getSessionType( ) != beanType ) {
|
||||
continue;
|
||||
}
|
||||
this.logger.debug( "Adding delegate from " + delegate.getClass( ) );
|
||||
bean.registerSubType( delegate );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package com.deepclone.lw.beans.user.abst;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.session.SessionTypeDefiner;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.SessionCommandException;
|
||||
import com.deepclone.lw.session.SessionStateException;
|
||||
|
||||
|
||||
|
||||
public abstract class StatefulSessionTypeDefiner
|
||||
implements SessionTypeDefiner
|
||||
{
|
||||
|
||||
private SessionSubTypeDelegate commonDelegate = null;
|
||||
|
||||
private Map< String , SessionSubTypeDelegate > subTypes = new HashMap< String , SessionSubTypeDelegate >( );
|
||||
|
||||
|
||||
protected abstract String initAuthToken( ServerSession session , String identifier , String sha1Hash ,
|
||||
String md5Hash );
|
||||
|
||||
|
||||
protected abstract String getSessionType( ServerSession session );
|
||||
|
||||
|
||||
protected final String getAuthToken( ServerSession session )
|
||||
{
|
||||
return session.get( "authenticationToken" , String.class );
|
||||
}
|
||||
|
||||
|
||||
public final void registerSubType( SessionSubTypeDelegate delegate )
|
||||
{
|
||||
String name = delegate.getName( );
|
||||
synchronized ( this.subTypes ) {
|
||||
if ( name == null ) {
|
||||
this.commonDelegate = delegate;
|
||||
} else {
|
||||
this.subTypes.put( delegate.getName( ) , delegate );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String updateSessionType( ServerSession session )
|
||||
{
|
||||
String type = this.getSessionType( session );
|
||||
session.put( "sessionState" , type );
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final String getState( ServerSession session )
|
||||
{
|
||||
return session.get( "sessionState" , String.class );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void authenticate( ServerSession session , String identifier , String sha1Hash , String md5Hash )
|
||||
throws SessionStateException
|
||||
{
|
||||
if ( this.isAuthenticated( session ) ) {
|
||||
throw new SessionStateException( );
|
||||
}
|
||||
|
||||
String token = this.initAuthToken( session , identifier , sha1Hash , md5Hash );
|
||||
if ( token == null ) {
|
||||
return;
|
||||
}
|
||||
session.put( "authenticationToken" , token );
|
||||
this.updateSessionType( session );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final boolean isAuthenticated( ServerSession session )
|
||||
{
|
||||
return ( this.getAuthToken( session ) != null );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final CommandResponse execute( ServerSession session , Command command )
|
||||
throws SessionStateException , SessionCommandException
|
||||
{
|
||||
if ( !this.isAuthenticated( session ) ) {
|
||||
throw new SessionStateException( );
|
||||
}
|
||||
|
||||
String type = this.updateSessionType( session );
|
||||
SessionSubTypeDelegate delegate;
|
||||
SessionSubTypeDelegate fallback;
|
||||
synchronized ( this.subTypes ) {
|
||||
delegate = this.subTypes.get( type );
|
||||
fallback = this.commonDelegate;
|
||||
}
|
||||
if ( delegate == null ) {
|
||||
if ( fallback == null ) {
|
||||
throw new SessionStateException( );
|
||||
} else {
|
||||
delegate = fallback;
|
||||
fallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
CommandResponse response;
|
||||
try {
|
||||
response = delegate.execute( session , command );
|
||||
} catch ( SessionCommandException e ) {
|
||||
if ( fallback != null ) {
|
||||
response = fallback.execute( session , command );
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
this.updateSessionType( session );
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package com.deepclone.lw.beans.user.admin;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.StatefulSessionTypeDefiner;
|
||||
import com.deepclone.lw.cmd.admin.users.SessionTerminationType;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.session.SessionManager;
|
||||
import com.deepclone.lw.sqld.admin.AdminRecord;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class AdminSessionDefinerBean
|
||||
extends StatefulSessionTypeDefiner
|
||||
{
|
||||
private Administration administration;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setSessionManager( SessionManager manager )
|
||||
{
|
||||
manager.registerSessionType( this );
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName( )
|
||||
{
|
||||
return "admin";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initialise( ServerSession session )
|
||||
{
|
||||
// EMPTY
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String initAuthToken( ServerSession session , String identifier , String sha1Hash , String md5Hash )
|
||||
{
|
||||
EmailAddress address = new EmailAddress( identifier );
|
||||
if ( !address.isValid( ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AdminRecord admin = this.administration.login( address , session.getChallenge( ) , sha1Hash , md5Hash , session
|
||||
.getAddress( ) );
|
||||
if ( admin == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
session.setExpirationDate( new Date( new Date( ).getTime( ) + 600000L ) );
|
||||
return ( (Integer) admin.getId( ) ).toString( );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getSessionType( ServerSession session )
|
||||
{
|
||||
int adminId = Integer.parseInt( session.get( "authenticationToken" , String.class ) );
|
||||
AdminRecord admin = this.administration.getAdmin( adminId );
|
||||
session.put( "admin" , admin );
|
||||
|
||||
// Administrator has been disabled
|
||||
if ( !admin.isActive( ) ) {
|
||||
session.terminate( SessionTerminationType.GONE );
|
||||
return null;
|
||||
}
|
||||
|
||||
return ( admin.getPassChangeRequired( ) ? "pass" : "main" );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void terminate( ServerSession session , SessionTerminationType reason )
|
||||
{
|
||||
String authToken = session.get( "authenticationToken" , String.class );
|
||||
if ( authToken != null ) {
|
||||
int adminId = Integer.parseInt( session.get( "authenticationToken" , String.class ) );
|
||||
this.administration.logout( adminId );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.deepclone.lw.beans.user.admin;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredSubTypeDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.abst.StatefulSessionTypeDefiner;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.SessionCommandException;
|
||||
|
||||
|
||||
|
||||
public abstract class AdminSessionSubType
|
||||
extends SessionCommandHandler
|
||||
implements AutowiredSubTypeDelegate
|
||||
{
|
||||
|
||||
@Override
|
||||
public Class< ? extends StatefulSessionTypeDefiner > getSessionType( )
|
||||
{
|
||||
return AdminSessionDefinerBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
throws SessionCommandException
|
||||
{
|
||||
session.setExpirationDate( new Date( new Date( ).getTime( ) + 1800000L ) );
|
||||
return this.executeDelegate( session , command );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.deepclone.lw.beans.user.admin.common;
|
||||
|
||||
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.sqld.admin.AdminRecord;
|
||||
|
||||
|
||||
|
||||
public abstract class AdminOperation
|
||||
{
|
||||
|
||||
protected Administrator getAdministrator( ServerSession session )
|
||||
{
|
||||
return this.convertAdministrator( session.get( "admin" , AdminRecord.class ) );
|
||||
}
|
||||
|
||||
|
||||
protected Administrator convertAdministrator( AdminRecord record )
|
||||
{
|
||||
Administrator admin = new Administrator( );
|
||||
admin.setId( record.getId( ) );
|
||||
admin.setAddress( record.getAddress( ) );
|
||||
admin.setName( record.getName( ) );
|
||||
admin.setPrivileges( record.getPrivileges( ) );
|
||||
admin.setPasswordChange( record.getPassChangeRequired( ) );
|
||||
return admin;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.deepclone.lw.beans.user.admin.common;
|
||||
|
||||
|
||||
import com.deepclone.lw.beans.user.admin.AdminSessionSubType;
|
||||
|
||||
|
||||
|
||||
public class CommonCommandsBean
|
||||
extends AdminSessionSubType
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getName( )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.deepclone.lw.beans.user.admin.common;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.cmd.CreateAuthChallengeCommand;
|
||||
import com.deepclone.lw.cmd.CreateAuthChallengeResponse;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.RandomStringGenerator;
|
||||
|
||||
|
||||
|
||||
public class CreateAuthChallengeCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private RandomStringGenerator challengeGenerator;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
@Qualifier( "authChallenges" )
|
||||
public void setChallangeGenerator( RandomStringGenerator rsg )
|
||||
{
|
||||
this.challengeGenerator = rsg;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return CommonCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return CreateAuthChallengeCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
String challenge = this.challengeGenerator.generate( );
|
||||
session.put( "tempChallenge" , challenge );
|
||||
return new CreateAuthChallengeResponse( challenge );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.deepclone.lw.beans.user.admin.common;
|
||||
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.cmd.admin.AdminResponse;
|
||||
import com.deepclone.lw.cmd.admin.NoOperationCommand;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class NoOperationCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return CommonCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return NoOperationCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
NoOperationCommand command = (NoOperationCommand) cParam;
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
|
||||
Privileges priv = command.getRequirePrivilege( );
|
||||
AdminResponse response;
|
||||
if ( priv == null ) {
|
||||
response = new AdminResponse( admin );
|
||||
} else {
|
||||
response = new AdminResponse( admin , admin.hasPrivilege( priv ) );
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package com.deepclone.lw.beans.user.admin.common;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.cmd.admin.SetPasswordCommand;
|
||||
import com.deepclone.lw.cmd.admin.SetPasswordResponse;
|
||||
import com.deepclone.lw.cmd.admin.SetPasswordResponse.PasswordChangeStatus;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.interfaces.acm.PasswordProhibitedException;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.Password;
|
||||
|
||||
|
||||
|
||||
public class SetPasswordCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private Administration administration;
|
||||
private int minPasswordStrength = 20;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
public void setMinPasswordStrength( int strength )
|
||||
{
|
||||
this.minPasswordStrength = strength;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return CommonCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return SetPasswordCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
SetPasswordCommand command = (SetPasswordCommand) cParam;
|
||||
|
||||
String challenge = session.get( "tempChallenge" , String.class );
|
||||
session.put( "tempChallenge" , null );
|
||||
|
||||
PasswordChangeStatus status = PasswordChangeStatus.OK;
|
||||
Password pwd = null;
|
||||
if ( "".equals( command.getPassword( ) ) ) {
|
||||
status = PasswordChangeStatus.EMPTY;
|
||||
} else if ( !command.getPassword( ).equals( command.getPasswordConfirm( ) ) ) {
|
||||
status = PasswordChangeStatus.MISMATCH;
|
||||
} else {
|
||||
pwd = new Password( command.getPassword( ) );
|
||||
if ( pwd.getStrength( ) < this.minPasswordStrength ) {
|
||||
status = PasswordChangeStatus.TOO_WEAK;
|
||||
}
|
||||
}
|
||||
|
||||
boolean authError;
|
||||
if ( status == PasswordChangeStatus.OK ) {
|
||||
try {
|
||||
authError = !this.administration.setPassword( admin.getId( ) , challenge , command.getSha1Auth( ) ,
|
||||
command.getMd5Auth( ) , pwd );
|
||||
} catch ( PasswordProhibitedException e ) {
|
||||
authError = false;
|
||||
status = PasswordChangeStatus.PROHIBITED;
|
||||
}
|
||||
} else {
|
||||
authError = false;
|
||||
}
|
||||
|
||||
if ( !authError && status == PasswordChangeStatus.OK ) {
|
||||
return new SetPasswordResponse( );
|
||||
}
|
||||
return new SetPasswordResponse( admin , authError , status );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.deepclone.lw.beans.user.admin.main;
|
||||
|
||||
|
||||
import com.deepclone.lw.beans.user.admin.AdminSessionSubType;
|
||||
|
||||
|
||||
|
||||
public class AdminCommandsBean
|
||||
extends AdminSessionSubType
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getName( )
|
||||
{
|
||||
return "main";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.deepclone.lw.beans.user.admin.main;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.cmd.admin.AdminOverviewCommand;
|
||||
import com.deepclone.lw.cmd.admin.AdminOverviewResponse;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class AdminOverviewCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private Administration administration;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return AdminOverviewCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
AdminOverviewResponse response = this.administration.getOverview( admin );
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bans;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bans.BansSummaryCommand;
|
||||
import com.deepclone.lw.cmd.admin.bans.BansSummaryResponse;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class BansSummaryCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private Administration administration;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return BansSummaryCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BANH ) ) {
|
||||
return new BansSummaryResponse( admin );
|
||||
}
|
||||
return this.administration.getBansSummary( admin );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bans;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bans.ConfirmBanCommand;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class ConfirmBanCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private Administration administration;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ConfirmBanCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BANH ) ) {
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
this.administration.confirmBan( admin , ( (ConfirmBanCommand) command ).getId( ) );
|
||||
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bans;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bans.LiftBanCommand;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class LiftBanCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private Administration administration;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return LiftBanCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BANH ) ) {
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
this.administration.liftBan( admin , ( (LiftBanCommand) command ).getId( ) );
|
||||
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bans;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bans.ListBansCommand;
|
||||
import com.deepclone.lw.cmd.admin.bans.ListBansResponse;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ListBansCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private Administration administration;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ListBansCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BANH ) ) {
|
||||
return new ListBansResponse( admin );
|
||||
}
|
||||
return this.administration.getBans( admin , ( (ListBansCommand) command ).getType( ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bans;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bans.RejectBanCommand;
|
||||
import com.deepclone.lw.cmd.admin.bans.RejectBanResponse;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class RejectBanCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private Administration administration;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return RejectBanCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BANH ) ) {
|
||||
return new RejectBanResponse( admin , true );
|
||||
}
|
||||
|
||||
RejectBanCommand command = (RejectBanCommand) cParam;
|
||||
int id = command.getId( );
|
||||
String reason = command.getReason( ).trim( );
|
||||
|
||||
if ( "".equals( reason ) ) {
|
||||
return new RejectBanResponse( admin , id );
|
||||
}
|
||||
|
||||
this.administration.rejectBan( admin , id , reason );
|
||||
return new RejectBanResponse( admin , false );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bans;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bans.RequestBanCommand;
|
||||
import com.deepclone.lw.cmd.admin.bans.RequestBanResponse;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class RequestBanCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private Administration administration;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return RequestBanCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BANH ) ) {
|
||||
return new RequestBanResponse( admin , true );
|
||||
}
|
||||
|
||||
RequestBanCommand command = (RequestBanCommand) cParam;
|
||||
String user = command.getUser( ).trim( );
|
||||
boolean empire = command.isEmpire( );
|
||||
String reason = command.getReason( ).trim( );
|
||||
|
||||
if ( "".equals( reason ) ) {
|
||||
return new RequestBanResponse( admin , RequestBanResponse.Error.NO_REASON , user , empire , reason );
|
||||
} else if ( "".equals( user ) ) {
|
||||
return new RequestBanResponse( admin , RequestBanResponse.Error.NOT_FOUND , user , empire , reason );
|
||||
}
|
||||
|
||||
return this.administration.requestBan( admin , user , empire , reason );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bt;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bt.BugsSummaryCommand;
|
||||
import com.deepclone.lw.cmd.admin.bt.BugsSummaryResponse;
|
||||
import com.deepclone.lw.interfaces.bt.AdminBugs;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class BugsSummaryCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AdminBugs bugs;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setBugs( AdminBugs bugs )
|
||||
{
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return BugsSummaryCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BUGT ) ) {
|
||||
return new BugsSummaryResponse( admin );
|
||||
}
|
||||
return this.bugs.getSummary( admin );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bt;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bt.GetSnapshotCommand;
|
||||
import com.deepclone.lw.cmd.admin.bt.GetSnapshotResponse;
|
||||
import com.deepclone.lw.interfaces.bt.AdminBugs;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class GetSnapshotCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AdminBugs bugs;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setBugs( AdminBugs bugs )
|
||||
{
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return GetSnapshotCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BUGT ) ) {
|
||||
return new GetSnapshotResponse( admin , true );
|
||||
}
|
||||
long id = ( (GetSnapshotCommand) cParam ).getBugId( );
|
||||
return this.bugs.getSnapshot( admin , id );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bt;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bt.ListBugsResponse;
|
||||
import com.deepclone.lw.cmd.bt.ListBugsCommand;
|
||||
import com.deepclone.lw.cmd.bt.data.BugStatus;
|
||||
import com.deepclone.lw.interfaces.bt.AdminBugs;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ListBugsCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AdminBugs bugs;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setBugs( AdminBugs bugs )
|
||||
{
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ListBugsCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BUGT ) ) {
|
||||
return new ListBugsResponse( admin );
|
||||
}
|
||||
|
||||
ListBugsCommand command = (ListBugsCommand) cParam;
|
||||
long first = command.getFirst( );
|
||||
int count = command.getCount( );
|
||||
BugStatus status = command.getStatus( );
|
||||
boolean own = command.isOwnOnly( );
|
||||
|
||||
return this.bugs.getBugs( admin , status , own , first , count );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bt;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bt.MergeReportsCommand;
|
||||
import com.deepclone.lw.cmd.admin.bt.MergeReportsResponse;
|
||||
import com.deepclone.lw.interfaces.bt.AdminBugs;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class MergeReportsCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private AdminBugs bugs;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setBugs( AdminBugs bugs )
|
||||
{
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return MergeReportsCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BUGT ) ) {
|
||||
return new MergeReportsResponse( admin , true );
|
||||
}
|
||||
|
||||
long id = ( (MergeReportsCommand) command ).getId1( );
|
||||
long mergeId = ( (MergeReportsCommand) command ).getId2( );
|
||||
|
||||
return this.bugs.mergeReports( admin , id , mergeId );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bt;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bt.ModerateCommentCommand;
|
||||
import com.deepclone.lw.interfaces.bt.AdminBugs;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class ModerateCommentCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AdminBugs bugs;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setBugs( AdminBugs bugs )
|
||||
{
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ModerateCommentCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( admin.hasPrivilege( Privileges.BUGT ) ) {
|
||||
ModerateCommentCommand mc = (ModerateCommentCommand) command;
|
||||
this.bugs.moderateComment( admin , mc.getId( ) , mc.isValidation( ) );
|
||||
}
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bt;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.ObjectNameError;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.bt.PostCommentCommand;
|
||||
import com.deepclone.lw.cmd.admin.bt.PostCommentResponse;
|
||||
import com.deepclone.lw.cmd.admin.bt.ViewBugResponse;
|
||||
import com.deepclone.lw.interfaces.bt.AdminBugs;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class PostCommentCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private AdminBugs bugs;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setBugs( AdminBugs bugs )
|
||||
{
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return PostCommentCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BUGT ) ) {
|
||||
return new PostCommentResponse( admin , true );
|
||||
}
|
||||
|
||||
long id = ( (PostCommentCommand) command ).getId( );
|
||||
String comment = ( (PostCommentCommand) command ).getComment( ).trim( );
|
||||
boolean pComment = ( (PostCommentCommand) command ).isPublicComment( );
|
||||
|
||||
ObjectNameError error;
|
||||
if ( "".equals( comment ) ) {
|
||||
error = ObjectNameError.EMPTY;
|
||||
} else if ( comment.length( ) < 30 ) {
|
||||
error = ObjectNameError.INVALID;
|
||||
} else {
|
||||
error = null;
|
||||
}
|
||||
|
||||
if ( error != null ) {
|
||||
ViewBugResponse response = this.bugs.getReport( admin , id );
|
||||
if ( response.getReport( ) == null ) {
|
||||
return new PostCommentResponse( admin , false );
|
||||
}
|
||||
return new PostCommentResponse( admin , response.getReport( ) , response.getEvents( ) , error , comment ,
|
||||
pComment );
|
||||
}
|
||||
|
||||
PostCommentResponse response = this.bugs.postComment( admin , id , comment , pComment );
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bt;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.ObjectNameError;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bt.ReportBugResponse;
|
||||
import com.deepclone.lw.cmd.bt.ReportBugCommand;
|
||||
import com.deepclone.lw.interfaces.bt.AdminBugs;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ReportBugCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private AdminBugs bugs;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setBugs( AdminBugs bugs )
|
||||
{
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ReportBugCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BUGT ) ) {
|
||||
return new ReportBugResponse( admin );
|
||||
}
|
||||
|
||||
ReportBugCommand command = (ReportBugCommand) cParam;
|
||||
String title = command.getTitle( ).trim( );
|
||||
String desc = command.getDescription( ).trim( );
|
||||
boolean isPublic = command.isPublicReport( );
|
||||
|
||||
ObjectNameError titleError;
|
||||
if ( "".equals( title ) ) {
|
||||
titleError = ObjectNameError.EMPTY;
|
||||
} else if ( title.length( ) < 10 || title.length( ) > 127 ) {
|
||||
titleError = ObjectNameError.INVALID;
|
||||
} else {
|
||||
titleError = null;
|
||||
}
|
||||
|
||||
ObjectNameError descError;
|
||||
if ( "".equals( desc ) ) {
|
||||
descError = ObjectNameError.EMPTY;
|
||||
} else if ( desc.length( ) < 30 ) {
|
||||
descError = ObjectNameError.INVALID;
|
||||
} else {
|
||||
descError = null;
|
||||
}
|
||||
|
||||
if ( descError != null || titleError != null ) {
|
||||
return new ReportBugResponse( admin , titleError , title , descError , desc , isPublic );
|
||||
}
|
||||
|
||||
return this.bugs.postReport( admin , title , desc , isPublic );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bt;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bt.ReportStatusCommand;
|
||||
import com.deepclone.lw.interfaces.bt.AdminBugs;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class ReportStatusCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AdminBugs bugs;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setBugs( AdminBugs bugs )
|
||||
{
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ReportStatusCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( admin.hasPrivilege( Privileges.BUGT ) ) {
|
||||
ReportStatusCommand rs = (ReportStatusCommand) command;
|
||||
this.bugs.setStatus( admin , rs.getId( ) , rs.getStatus( ) );
|
||||
}
|
||||
return new NullResponse( );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bt;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bt.ReportVisibilityCommand;
|
||||
import com.deepclone.lw.interfaces.bt.AdminBugs;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class ReportVisibilityCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AdminBugs bugs;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setBugs( AdminBugs bugs )
|
||||
{
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ReportVisibilityCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( admin.hasPrivilege( Privileges.BUGT ) ) {
|
||||
ReportVisibilityCommand rs = (ReportVisibilityCommand) command;
|
||||
this.bugs.toggleVisibility( admin , rs.getId( ) );
|
||||
}
|
||||
return new NullResponse( );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bt;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bt.ValidateReportCommand;
|
||||
import com.deepclone.lw.interfaces.bt.AdminBugs;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class ValidateReportCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AdminBugs bugs;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setBugs( AdminBugs bugs )
|
||||
{
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ValidateReportCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( admin.hasPrivilege( Privileges.BUGT ) ) {
|
||||
ValidateReportCommand vr = (ValidateReportCommand) command;
|
||||
int creds = vr.getGrantCredits( );
|
||||
if ( creds < 0 ) {
|
||||
creds = 0;
|
||||
} else if ( creds > 3 ) {
|
||||
creds = 3;
|
||||
}
|
||||
this.bugs.validateReport( admin , vr.getId( ) , vr.getStatus( ) , vr.isPublicReport( ) , creds , vr
|
||||
.isSnapshot( ) );
|
||||
}
|
||||
return new NullResponse( );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.bt;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.bt.ViewBugResponse;
|
||||
import com.deepclone.lw.cmd.bt.ViewBugCommand;
|
||||
import com.deepclone.lw.interfaces.bt.AdminBugs;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ViewBugCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AdminBugs bugs;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setBugs( AdminBugs bugs )
|
||||
{
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ViewBugCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.BUGT ) ) {
|
||||
return new ViewBugResponse( admin , true );
|
||||
}
|
||||
|
||||
long id = ( (ViewBugCommand) command ).getId( );
|
||||
return this.bugs.getReport( admin , id );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.cnst;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.constants.Category;
|
||||
import com.deepclone.lw.cmd.admin.constants.Definition;
|
||||
import com.deepclone.lw.cmd.admin.constants.GetConstantsCommand;
|
||||
import com.deepclone.lw.cmd.admin.constants.GetConstantsResponse;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.sys.ConstantDefinition;
|
||||
import com.deepclone.lw.interfaces.sys.ConstantsAdministration;
|
||||
import com.deepclone.lw.interfaces.sys.ConstantsManager;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class GetConstantsCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private ConstantsManager constants;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setConstants( ConstantsManager constants )
|
||||
{
|
||||
this.constants = constants;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return GetConstantsCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.CNST ) ) {
|
||||
return new GetConstantsResponse( admin );
|
||||
}
|
||||
|
||||
ConstantsAdministration cAdmin = this.constants.getAdminSession( admin.getId( ) );
|
||||
List< Category > cats = new LinkedList< Category >( );
|
||||
for ( String cName : cAdmin.getCategories( ) ) {
|
||||
List< Definition > defs = new LinkedList< Definition >( );
|
||||
for ( ConstantDefinition cnst : cAdmin.getConstants( cName ) ) {
|
||||
Definition def = new Definition( );
|
||||
def.setName( cnst.name );
|
||||
def.setDescription( cnst.description );
|
||||
def.setValue( cnst.defaultValue );
|
||||
def.setMinValue( cnst.minValue );
|
||||
def.setMaxValue( cnst.maxValue );
|
||||
defs.add( def );
|
||||
}
|
||||
|
||||
cats.add( new Category( cName , defs ) );
|
||||
}
|
||||
|
||||
return new GetConstantsResponse( admin , cats );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.cnst;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.constants.Category;
|
||||
import com.deepclone.lw.cmd.admin.constants.Definition;
|
||||
import com.deepclone.lw.cmd.admin.constants.SetConstantCommand;
|
||||
import com.deepclone.lw.cmd.admin.constants.SetConstantResponse;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.sys.ConstantDefinition;
|
||||
import com.deepclone.lw.interfaces.sys.ConstantsAdministration;
|
||||
import com.deepclone.lw.interfaces.sys.ConstantsManager;
|
||||
import com.deepclone.lw.interfaces.sys.InvalidConstantValue;
|
||||
import com.deepclone.lw.interfaces.sys.UnknownConstantError;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class SetConstantCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private ConstantsManager constants;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setConstants( ConstantsManager constants )
|
||||
{
|
||||
this.constants = constants;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return SetConstantCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.CNST ) ) {
|
||||
return new SetConstantResponse( admin , true );
|
||||
}
|
||||
|
||||
ConstantsAdministration cAdmin = this.constants.getAdminSession( admin.getId( ) );
|
||||
SetConstantCommand command = (SetConstantCommand) cParam;
|
||||
try {
|
||||
cAdmin.setConstant( command.getName( ) , command.getValue( ) );
|
||||
return new SetConstantResponse( admin , false );
|
||||
} catch ( UnknownConstantError e ) {
|
||||
return new SetConstantResponse( admin , false );
|
||||
} catch ( InvalidConstantValue e ) {
|
||||
// EMPTY
|
||||
}
|
||||
|
||||
List< Category > cats = new LinkedList< Category >( );
|
||||
for ( String cName : cAdmin.getCategories( ) ) {
|
||||
List< Definition > defs = new LinkedList< Definition >( );
|
||||
for ( ConstantDefinition cnst : cAdmin.getConstants( cName ) ) {
|
||||
Definition def = new Definition( );
|
||||
def.setName( cnst.name );
|
||||
def.setDescription( cnst.description );
|
||||
def.setValue( cnst.defaultValue );
|
||||
def.setMinValue( cnst.minValue );
|
||||
def.setMaxValue( cnst.maxValue );
|
||||
defs.add( def );
|
||||
}
|
||||
|
||||
cats.add( new Category( cName , defs ) );
|
||||
}
|
||||
|
||||
return new SetConstantResponse( admin , cats , command.getName( ) , command.getValue( ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.i18n;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.i18n.ChangeLanguageCommand;
|
||||
import com.deepclone.lw.cmd.admin.i18n.ChangeLanguageResponse;
|
||||
import com.deepclone.lw.cmd.admin.i18n.I18NString;
|
||||
import com.deepclone.lw.cmd.admin.i18n.Language;
|
||||
import com.deepclone.lw.interfaces.i18n.I18NAdministration;
|
||||
import com.deepclone.lw.interfaces.i18n.I18NManager;
|
||||
import com.deepclone.lw.interfaces.i18n.TranslationException;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ChangeLanguageCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private I18NManager i18n;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setI18n( I18NManager i18n )
|
||||
{
|
||||
this.i18n = i18n;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ChangeLanguageCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.I18N ) ) {
|
||||
return new ChangeLanguageResponse( admin );
|
||||
}
|
||||
|
||||
ChangeLanguageCommand command = (ChangeLanguageCommand) cParam;
|
||||
String lId = command.getId( );
|
||||
String newName = command.getName( ).trim( );
|
||||
|
||||
I18NAdministration i18n = this.i18n.getAdminSession( admin.getId( ) );
|
||||
if ( !i18n.getLanguages( ).contains( lId ) ) {
|
||||
return new ChangeLanguageResponse( admin , null );
|
||||
}
|
||||
|
||||
Language language = new Language( );
|
||||
List< I18NString > strings = new LinkedList< I18NString >( );
|
||||
boolean error = ( newName.length( ) < 2 || newName.length( ) > 48 );
|
||||
language.setId( lId );
|
||||
language.setName( newName );
|
||||
try {
|
||||
if ( error ) {
|
||||
for ( String sId : i18n.getStrings( ) ) {
|
||||
strings.add( new I18NString( sId , i18n.getTranslation( lId , sId ) ) );
|
||||
}
|
||||
} else {
|
||||
i18n.setLanguageName( lId , newName );
|
||||
}
|
||||
language.setCompletion( (int) Math.floor( i18n.getLanguageSupport( lId ) * 100 ) );
|
||||
} catch ( TranslationException e ) {
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
|
||||
return error ? new ChangeLanguageResponse( admin , language , strings ) : new ChangeLanguageResponse( admin ,
|
||||
language );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.i18n;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.i18n.GetLanguageCommand;
|
||||
import com.deepclone.lw.cmd.admin.i18n.GetLanguageResponse;
|
||||
import com.deepclone.lw.cmd.admin.i18n.I18NString;
|
||||
import com.deepclone.lw.cmd.admin.i18n.Language;
|
||||
import com.deepclone.lw.interfaces.i18n.I18NAdministration;
|
||||
import com.deepclone.lw.interfaces.i18n.I18NManager;
|
||||
import com.deepclone.lw.interfaces.i18n.UnknownLanguageException;
|
||||
import com.deepclone.lw.interfaces.i18n.UnknownStringException;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class GetLanguageCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private I18NManager i18n;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setI18n( I18NManager i18n )
|
||||
{
|
||||
this.i18n = i18n;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return GetLanguageCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.I18N ) ) {
|
||||
return new GetLanguageResponse( admin );
|
||||
}
|
||||
|
||||
String lId = ( (GetLanguageCommand) cParam ).getLanguage( );
|
||||
I18NAdministration i18n = this.i18n.getAdminSession( admin.getId( ) );
|
||||
|
||||
Language language = new Language( );
|
||||
List< I18NString > strings = new LinkedList< I18NString >( );
|
||||
language.setId( lId );
|
||||
try {
|
||||
language.setName( i18n.getLanguageName( lId ) );
|
||||
language.setCompletion( (int) Math.floor( i18n.getLanguageSupport( lId ) * 100 ) );
|
||||
for ( String sId : i18n.getStrings( ) ) {
|
||||
strings.add( new I18NString( sId , i18n.getTranslation( lId , sId ) ) );
|
||||
}
|
||||
} catch ( UnknownLanguageException e ) {
|
||||
return new GetLanguageResponse( admin , null , null );
|
||||
} catch ( UnknownStringException e ) {
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
|
||||
return new GetLanguageResponse( admin , language , strings );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.i18n;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.i18n.ChangeLanguageResponse;
|
||||
import com.deepclone.lw.cmd.admin.i18n.I18NString;
|
||||
import com.deepclone.lw.cmd.admin.i18n.Language;
|
||||
import com.deepclone.lw.cmd.admin.i18n.SetStringCommand;
|
||||
import com.deepclone.lw.cmd.admin.i18n.SetStringResponse;
|
||||
import com.deepclone.lw.interfaces.i18n.I18NAdministration;
|
||||
import com.deepclone.lw.interfaces.i18n.I18NManager;
|
||||
import com.deepclone.lw.interfaces.i18n.TranslationException;
|
||||
import com.deepclone.lw.interfaces.i18n.UnknownLanguageException;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class SetStringCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private I18NManager i18n;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setI18n( I18NManager i18n )
|
||||
{
|
||||
this.i18n = i18n;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return SetStringCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.I18N ) ) {
|
||||
return new ChangeLanguageResponse( admin );
|
||||
}
|
||||
|
||||
SetStringCommand command = (SetStringCommand) cParam;
|
||||
String lId = command.getLanguage( );
|
||||
String sId = command.getId( );
|
||||
String text = command.getText( ).trim( );
|
||||
|
||||
I18NAdministration i18n = this.i18n.getAdminSession( admin.getId( ) );
|
||||
if ( !i18n.getLanguages( ).contains( lId ) ) {
|
||||
return new SetStringResponse( admin , null );
|
||||
}
|
||||
|
||||
Language language = new Language( );
|
||||
language.setId( lId );
|
||||
|
||||
if ( !i18n.getStrings( ).contains( sId ) ) {
|
||||
try {
|
||||
language.setName( i18n.getLanguageName( lId ) );
|
||||
language.setCompletion( (int) Math.floor( i18n.getLanguageSupport( lId ) * 100 ) );
|
||||
} catch ( UnknownLanguageException e ) {
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
return new SetStringResponse( admin , language );
|
||||
}
|
||||
|
||||
boolean error = "".equals( text );
|
||||
List< I18NString > strings = new LinkedList< I18NString >( );
|
||||
try {
|
||||
if ( error ) {
|
||||
for ( String s : i18n.getStrings( ) ) {
|
||||
strings.add( new I18NString( s , i18n.getTranslation( lId , s ) ) );
|
||||
}
|
||||
} else {
|
||||
i18n.updateTranslation( lId , sId , text );
|
||||
}
|
||||
language.setName( i18n.getLanguageName( lId ) );
|
||||
language.setCompletion( (int) Math.floor( i18n.getLanguageSupport( lId ) * 100 ) );
|
||||
} catch ( TranslationException e ) {
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
|
||||
return error ? new SetStringResponse( admin , language , strings , sId ) : new SetStringResponse( admin ,
|
||||
language );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.i18n;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.i18n.Language;
|
||||
import com.deepclone.lw.cmd.admin.i18n.ViewLanguagesCommand;
|
||||
import com.deepclone.lw.cmd.admin.i18n.ViewLanguagesResponse;
|
||||
import com.deepclone.lw.interfaces.i18n.I18NAdministration;
|
||||
import com.deepclone.lw.interfaces.i18n.I18NManager;
|
||||
import com.deepclone.lw.interfaces.i18n.UnknownLanguageException;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ViewLanguagesCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private I18NManager i18n;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setI18n( I18NManager i18n )
|
||||
{
|
||||
this.i18n = i18n;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ViewLanguagesCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.I18N ) ) {
|
||||
return new ViewLanguagesResponse( admin );
|
||||
}
|
||||
|
||||
I18NAdministration i18n = this.i18n.getAdminSession( admin.getId( ) );
|
||||
List< Language > languages = new LinkedList< Language >( );
|
||||
for ( String lang : i18n.getLanguages( ) ) {
|
||||
Language language = new Language( );
|
||||
language.setId( lang );
|
||||
try {
|
||||
language.setName( i18n.getLanguageName( lang ) );
|
||||
language.setCompletion( (int) Math.floor( i18n.getLanguageSupport( lang ) * 100 ) );
|
||||
} catch ( UnknownLanguageException e ) {
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
languages.add( language );
|
||||
}
|
||||
|
||||
return new ViewLanguagesResponse( admin , languages );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.logs;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.logs.GetEntryCommand;
|
||||
import com.deepclone.lw.cmd.admin.logs.GetEntryResponse;
|
||||
import com.deepclone.lw.interfaces.eventlog.LogReader;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class GetEntryCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private LogReader logReader;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setLogReader( LogReader logReader )
|
||||
{
|
||||
this.logReader = logReader;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return GetEntryCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.LOGS ) ) {
|
||||
return new GetEntryResponse( admin , true );
|
||||
}
|
||||
GetEntryCommand command = (GetEntryCommand) cParam;
|
||||
return this.logReader.getEntry( admin , command.getId( ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.logs;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.logs.ViewLogCommand;
|
||||
import com.deepclone.lw.cmd.admin.logs.ViewLogResponse;
|
||||
import com.deepclone.lw.interfaces.eventlog.LogReader;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ViewLogsCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private LogReader logReader;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setLogReader( LogReader logReader )
|
||||
{
|
||||
this.logReader = logReader;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ViewLogCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.LOGS ) ) {
|
||||
return new ViewLogResponse( admin );
|
||||
}
|
||||
ViewLogCommand command = (ViewLogCommand) cParam;
|
||||
return this.logReader.getLog( admin , command.getType( ) , command.getFirstEntry( ) , command.getCount( ) ,
|
||||
command.getMinLogLevel( ) , command.getComponent( ) , command.isExceptionOnly( ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.mntm;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.ObjectNameError;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.mntm.EnableMaintenanceCommand;
|
||||
import com.deepclone.lw.cmd.admin.mntm.MaintenanceChangeResponse;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.sys.MaintenanceData;
|
||||
import com.deepclone.lw.interfaces.sys.MaintenanceStatusException;
|
||||
import com.deepclone.lw.interfaces.sys.SystemStatus;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class EnableMaintenanceCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private SystemStatus systemStatus;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setSystemStatus( SystemStatus systemStatus )
|
||||
{
|
||||
this.systemStatus = systemStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return EnableMaintenanceCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.MNTM ) ) {
|
||||
return new MaintenanceChangeResponse( admin , true );
|
||||
}
|
||||
|
||||
String reason = ( (EnableMaintenanceCommand) command ).getReason( );
|
||||
ObjectNameError one;
|
||||
if ( "".equals( reason ) ) {
|
||||
one = ObjectNameError.EMPTY;
|
||||
} else if ( reason.length( ) < 10 ) {
|
||||
one = ObjectNameError.INVALID;
|
||||
} else {
|
||||
one = null;
|
||||
}
|
||||
|
||||
int duration = ( (EnableMaintenanceCommand) command ).getDuration( );
|
||||
if ( duration < 1 || one != null ) {
|
||||
MaintenanceData data = this.systemStatus.checkMaintenance( );
|
||||
if ( data == null ) {
|
||||
data = new MaintenanceData( null , null , null );
|
||||
}
|
||||
return new MaintenanceChangeResponse( admin , data.reason , data.start , data.end , reason , one , duration );
|
||||
}
|
||||
|
||||
try {
|
||||
this.systemStatus.startMaintenance( admin.getId( ) , reason , duration );
|
||||
} catch ( MaintenanceStatusException e ) {
|
||||
// Do nothing
|
||||
}
|
||||
return new MaintenanceChangeResponse( admin , false );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.mntm;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.mntm.EndMaintenanceCommand;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.sys.MaintenanceStatusException;
|
||||
import com.deepclone.lw.interfaces.sys.SystemStatus;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class EndMaintenanceCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private SystemStatus systemStatus;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setSystemStatus( SystemStatus systemStatus )
|
||||
{
|
||||
this.systemStatus = systemStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return EndMaintenanceCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( admin.hasPrivilege( Privileges.MNTM ) ) {
|
||||
try {
|
||||
this.systemStatus.endMaintenance( admin.getId( ) );
|
||||
} catch ( MaintenanceStatusException e ) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.mntm;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.mntm.ExtendMaintenanceCommand;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.sys.MaintenanceStatusException;
|
||||
import com.deepclone.lw.interfaces.sys.SystemStatus;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class ExtendMaintenanceCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private SystemStatus systemStatus;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setSystemStatus( SystemStatus systemStatus )
|
||||
{
|
||||
this.systemStatus = systemStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ExtendMaintenanceCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
int duration = ( (ExtendMaintenanceCommand) command ).getDuration( );
|
||||
if ( duration >= 1 ) {
|
||||
try {
|
||||
this.systemStatus.updateMaintenance( admin.getId( ) , duration );
|
||||
} catch ( MaintenanceStatusException e ) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.mntm;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.mntm.MaintenanceStatusCommand;
|
||||
import com.deepclone.lw.cmd.admin.mntm.MaintenanceStatusResponse;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.sys.MaintenanceData;
|
||||
import com.deepclone.lw.interfaces.sys.SystemStatus;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class MaintenanceStatusCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private SystemStatus systemStatus;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setSystemStatus( SystemStatus systemStatus )
|
||||
{
|
||||
this.systemStatus = systemStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return MaintenanceStatusCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.MNTM ) ) {
|
||||
return new MaintenanceStatusResponse( admin , true );
|
||||
}
|
||||
|
||||
MaintenanceData m = this.systemStatus.checkMaintenance( );
|
||||
if ( m == null ) {
|
||||
return new MaintenanceStatusResponse( admin , false );
|
||||
}
|
||||
return new MaintenanceStatusResponse( admin , m.reason , m.start , m.end );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.msgs;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.msgdata.MessageType;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.msg.ComposeMessageCommand;
|
||||
import com.deepclone.lw.cmd.admin.msg.ComposeMessageResponse;
|
||||
import com.deepclone.lw.interfaces.msg.AdminMessages;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ComposeMessageCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private AdminMessages messages;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setMessages( AdminMessages messages )
|
||||
{
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ComposeMessageCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
ComposeMessageCommand command = (ComposeMessageCommand) cParam;
|
||||
|
||||
MessageType type = command.getType( );
|
||||
if ( type == MessageType.INTERNAL ) {
|
||||
type = MessageType.EMPIRE;
|
||||
}
|
||||
String target = command.getTarget( );
|
||||
String title = command.getSubject( ).trim( );
|
||||
String contents = command.getContents( ).trim( );
|
||||
|
||||
boolean titleError = ( title.length( ) < 2 || title.length( ) > 64 );
|
||||
boolean contentsError = ( contents.length( ) < 2 );
|
||||
|
||||
ComposeMessageResponse response;
|
||||
if ( command.getReplyTo( ) != null && command.getInbox( ) != null ) {
|
||||
response = this.messages.sendReply( admin , command.getInbox( ) , command.getReplyTo( ) , type , target ,
|
||||
title , contents , titleError || contentsError );
|
||||
} else {
|
||||
response = this.messages.sendMessage( admin , type , target , title , contents , titleError
|
||||
|| contentsError );
|
||||
}
|
||||
response.setTitleError( titleError );
|
||||
response.setContentsError( contentsError );
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.msgs;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.msg.GetMessagesCommand;
|
||||
import com.deepclone.lw.interfaces.msg.AdminMessages;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class GetMessagesCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private AdminMessages messages;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setMessages( AdminMessages messages )
|
||||
{
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return GetMessagesCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
GetMessagesCommand command = (GetMessagesCommand) cParam;
|
||||
return this.messages.getMessages( this.getAdministrator( session ) , command.isInbox( ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.msgs;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.msg.MessageBoxCommand;
|
||||
import com.deepclone.lw.interfaces.msg.AdminMessages;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class MessageBoxCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private AdminMessages messages;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setMessages( AdminMessages messages )
|
||||
{
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return MessageBoxCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
MessageBoxCommand command = (MessageBoxCommand) cParam;
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
|
||||
long[] selection = command.getSelection( );
|
||||
if ( selection != null && selection.length == 0 ) {
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
switch ( command.getAction( ) ) {
|
||||
case DELETE:
|
||||
this.messages.deleteMessages( admin , command.isInbox( ) , selection );
|
||||
break;
|
||||
case MARK_READ:
|
||||
this.messages.markRead( admin , selection );
|
||||
break;
|
||||
case MARK_UNREAD:
|
||||
this.messages.markUnread( admin , selection );
|
||||
break;
|
||||
}
|
||||
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.msgs;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.msgdata.MessageType;
|
||||
import com.deepclone.lw.cmd.admin.msg.PrepareMessageCommand;
|
||||
import com.deepclone.lw.interfaces.msg.AdminMessages;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class PrepareMessageCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private AdminMessages messages;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setMessages( AdminMessages messages )
|
||||
{
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return PrepareMessageCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
PrepareMessageCommand command = (PrepareMessageCommand) cParam;
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
MessageType type = command.getType( );
|
||||
|
||||
if ( type == null ) {
|
||||
return this.messages.prepareBlankMessage( admin );
|
||||
} else if ( type == MessageType.INTERNAL ) {
|
||||
return this.messages.prepareReply( admin , command.getInbox( ) , command.getId( ) );
|
||||
}
|
||||
return this.messages.prepareMessageTo( admin , type , command.getId( ).intValue( ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.msgs;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.msg.ReadMessageCommand;
|
||||
import com.deepclone.lw.interfaces.msg.AdminMessages;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ReadMessageCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private AdminMessages messages;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setMessages( AdminMessages messages )
|
||||
{
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ReadMessageCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
ReadMessageCommand command = (ReadMessageCommand) cParam;
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
return this.messages.getMessage( admin , command.isInbox( ) , command.getId( ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.msgs;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.AdminResponse;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.msg.SendSpamCommand;
|
||||
import com.deepclone.lw.interfaces.msg.AdminMessages;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class SendSpamCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AdminMessages messages;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setMessages( AdminMessages messages )
|
||||
{
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return SendSpamCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.SPAM ) ) {
|
||||
return new AdminResponse( admin , false );
|
||||
}
|
||||
|
||||
SendSpamCommand command = (SendSpamCommand) cParam;
|
||||
this.messages.sendSpam( admin , command.getTitle( ) , command.getBody( ) );
|
||||
return new AdminResponse( admin );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.names;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.naming.GetNamesCommand;
|
||||
import com.deepclone.lw.cmd.admin.naming.GetNamesResponse;
|
||||
import com.deepclone.lw.interfaces.naming.NamesManager;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class GetNamesCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private NamesManager namesManager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setNamesManager( NamesManager namesManager )
|
||||
{
|
||||
this.namesManager = namesManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return GetNamesCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.NAME ) ) {
|
||||
return new GetNamesResponse( admin );
|
||||
}
|
||||
return this.namesManager.getNames( admin , ( (GetNamesCommand) command ).getType( ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.names;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.naming.NameAction;
|
||||
import com.deepclone.lw.cmd.admin.naming.NameType;
|
||||
import com.deepclone.lw.cmd.admin.naming.NamesActionCommand;
|
||||
import com.deepclone.lw.interfaces.naming.NamesManager;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class NamesActionCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private NamesManager namesManager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setNamesManager( NamesManager namesManager )
|
||||
{
|
||||
this.namesManager = namesManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return NamesActionCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.NAME ) ) {
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
NamesActionCommand command = (NamesActionCommand) cParam;
|
||||
NameType type = command.getType( );
|
||||
NameAction action = command.getAction( );
|
||||
int[] ids = command.getIdentifiers( );
|
||||
if ( ids.length == 0 ) {
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
switch ( action ) {
|
||||
case VALIDATE:
|
||||
if ( type != NameType.ALLIANCE && type != NameType.EMPIRE ) {
|
||||
this.namesManager.validateMapNames( admin , ids );
|
||||
}
|
||||
break;
|
||||
case REJECT:
|
||||
case REJECT_BAN:
|
||||
if ( type != NameType.ALLIANCE && type != NameType.EMPIRE ) {
|
||||
this.namesManager.rejectMapNames( admin , ids , action == NameAction.REJECT_BAN );
|
||||
} else if ( type == NameType.ALLIANCE ) {
|
||||
this.namesManager.rejectAllianceNames( admin , ids );
|
||||
} else if ( type == NameType.EMPIRE ) {
|
||||
this.namesManager.rejectEmpireNames( admin , ids , action == NameAction.REJECT_BAN );
|
||||
}
|
||||
break;
|
||||
case RESET:
|
||||
if ( type == NameType.MAP_CHANGED || type == NameType.MAP_VALIDATED ) {
|
||||
this.namesManager.allowMapNameChanges( admin , ids );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return new NullResponse( );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.names;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.naming.NamesSummaryCommand;
|
||||
import com.deepclone.lw.cmd.admin.naming.NamesSummaryResponse;
|
||||
import com.deepclone.lw.interfaces.naming.NamesManager;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class NamesSummaryCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private NamesManager namesManager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setNamesManager( NamesManager namesManager )
|
||||
{
|
||||
this.namesManager = namesManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return NamesSummaryCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.NAME ) ) {
|
||||
return new NamesSummaryResponse( admin );
|
||||
}
|
||||
return this.namesManager.getSummary( admin );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.prefs;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.prefs.GetPrefDefaultsCommand;
|
||||
import com.deepclone.lw.cmd.admin.prefs.PrefDefaultsResponse;
|
||||
import com.deepclone.lw.interfaces.prefs.PreferenceDefinitions;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class GetPrefDefaultsCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private PreferenceDefinitions preferences;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setPreferences( PreferenceDefinitions preferences )
|
||||
{
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return GetPrefDefaultsCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.PREF ) ) {
|
||||
return new PrefDefaultsResponse( admin );
|
||||
}
|
||||
|
||||
return new PrefDefaultsResponse( admin , this.preferences.getDefaults( ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.prefs;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.prefs.SetPrefDefaultCommand;
|
||||
import com.deepclone.lw.interfaces.prefs.PreferenceDefinitions;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class SetPrefDefaultCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private PreferenceDefinitions preferences;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setPreferences( PreferenceDefinitions preferences )
|
||||
{
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return SetPrefDefaultCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( admin.hasPrivilege( Privileges.PREF ) ) {
|
||||
SetPrefDefaultCommand command = (SetPrefDefaultCommand) cParam;
|
||||
this.preferences.setDefault( admin , command.getPreference( ) , command.getValue( ) );
|
||||
}
|
||||
return new NullResponse( );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.su;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.ObjectNameValidatorBean;
|
||||
import com.deepclone.lw.cmd.ObjectNameError;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.su.AddAdministratorCommand;
|
||||
import com.deepclone.lw.cmd.admin.su.AddAdministratorResponse;
|
||||
import com.deepclone.lw.cmd.admin.su.AddAdministratorResponse.AddressError;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class AddAdministratorCommandDelegateBean
|
||||
extends SuperUserOperation
|
||||
{
|
||||
|
||||
private Administration administration;
|
||||
private ObjectNameValidatorBean validator;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setValidator( ObjectNameValidatorBean validator )
|
||||
{
|
||||
this.validator = validator;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return AddAdministratorCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected CommandResponse handleCommand( Administrator admin , Command cParam )
|
||||
{
|
||||
AddAdministratorCommand command = (AddAdministratorCommand) cParam;
|
||||
|
||||
// Check name
|
||||
String name = command.getAppearAs( );
|
||||
ObjectNameError nameError;
|
||||
if ( "".equals( name ) ) {
|
||||
nameError = ObjectNameError.EMPTY;
|
||||
} else {
|
||||
nameError = this.validator.customValidate( name , 2 , 64 );
|
||||
}
|
||||
|
||||
// Check address
|
||||
String aStr = command.getAddress( );
|
||||
AddressError addrError;
|
||||
if ( "".equals( aStr ) ) {
|
||||
addrError = AddressError.EMPTY;
|
||||
} else {
|
||||
EmailAddress address = new EmailAddress( aStr );
|
||||
if ( address.isValid( ) ) {
|
||||
addrError = null;
|
||||
} else {
|
||||
addrError = AddressError.INVALID;
|
||||
}
|
||||
aStr = address.getAddress( );
|
||||
}
|
||||
|
||||
// Check privileges
|
||||
int privileges = 0;
|
||||
for ( Privileges priv : command.getPrivileges( )) {
|
||||
privileges = priv.grant( privileges );
|
||||
}
|
||||
boolean privError = ( privileges == 0 );
|
||||
|
||||
// If we already have errors, return
|
||||
if ( addrError != null || nameError != null || privError ) {
|
||||
return new AddAdministratorResponse( admin , addrError , aStr , nameError , name , privError , privileges );
|
||||
}
|
||||
|
||||
return this.administration.createAdmin( admin , aStr , name , privileges );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected CommandResponse insufficientPrivileges( Administrator admin )
|
||||
{
|
||||
return new AddAdministratorResponse( admin , true );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.su;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.su.ListAdministratorsCommand;
|
||||
import com.deepclone.lw.cmd.admin.su.ListAdministratorsResponse;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.sqld.admin.AdminRecord;
|
||||
|
||||
|
||||
|
||||
public class ListAdministratorsCommandDelegateBean
|
||||
extends SuperUserOperation
|
||||
{
|
||||
|
||||
private Administration administration;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ListAdministratorsCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected CommandResponse handleCommand( Administrator admin , Command command )
|
||||
{
|
||||
List< Administrator > result = new LinkedList< Administrator >( );
|
||||
for ( AdminRecord record : this.administration.listAdministrators( ) ) {
|
||||
result.add( this.convertAdministrator( record ) );
|
||||
}
|
||||
return new ListAdministratorsResponse( admin , result );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected CommandResponse insufficientPrivileges( Administrator admin )
|
||||
{
|
||||
return new ListAdministratorsResponse( admin );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.su;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.su.ResetAdminPasswordCommand;
|
||||
import com.deepclone.lw.cmd.admin.su.ViewAdministratorResponse;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.sqld.admin.AdminRecord;
|
||||
|
||||
|
||||
|
||||
public class ResetAdminPasswordCommandDelegateBean
|
||||
extends SUExistingOperation
|
||||
{
|
||||
private Administration administration;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ResetAdminPasswordCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected CommandResponse handleCommand( Administrator admin , Command cParam )
|
||||
{
|
||||
ResetAdminPasswordCommand command = (ResetAdminPasswordCommand) cParam;
|
||||
if ( admin.getId( ) == command.getIdentifier( ) ) {
|
||||
return new ViewAdministratorResponse( admin , admin );
|
||||
}
|
||||
|
||||
AdminRecord record = this.administration.resetPassword( admin , command.getIdentifier( ) );
|
||||
if ( record == null ) {
|
||||
return this.adminNotFound( admin );
|
||||
}
|
||||
return new ViewAdministratorResponse( admin , this.convertAdministrator( record ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.su;
|
||||
|
||||
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.su.ViewAdministratorResponse;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
abstract class SUExistingOperation
|
||||
extends SuperUserOperation
|
||||
{
|
||||
|
||||
protected final CommandResponse adminNotFound( Administrator admin )
|
||||
{
|
||||
return new ViewAdministratorResponse( admin , false );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected CommandResponse insufficientPrivileges( Administrator admin )
|
||||
{
|
||||
return new ViewAdministratorResponse( admin , true );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.su;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.su.SetPrivilegesCommand;
|
||||
import com.deepclone.lw.cmd.admin.su.ViewAdministratorResponse;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.sqld.admin.AdminRecord;
|
||||
|
||||
|
||||
|
||||
public class SetPrivilegesCommandDelegateBean
|
||||
extends SUExistingOperation
|
||||
{
|
||||
private Administration administration;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return SetPrivilegesCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected CommandResponse handleCommand( Administrator admin , Command cParam )
|
||||
{
|
||||
SetPrivilegesCommand command = (SetPrivilegesCommand) cParam;
|
||||
if ( command.getIdentifier( ) == admin.getId( ) ) {
|
||||
return new ViewAdministratorResponse( admin , admin );
|
||||
}
|
||||
|
||||
AdminRecord record = this.administration.setPrivileges( admin , command.getIdentifier( ) , command
|
||||
.getPrivileges( ) );
|
||||
if ( record == null ) {
|
||||
return this.adminNotFound( admin );
|
||||
}
|
||||
return new ViewAdministratorResponse( admin , this.convertAdministrator( record ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.su;
|
||||
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
abstract class SuperUserOperation
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.SUPER ) ) {
|
||||
return this.insufficientPrivileges( admin );
|
||||
}
|
||||
return this.handleCommand( admin , command );
|
||||
}
|
||||
|
||||
|
||||
protected abstract CommandResponse handleCommand( Administrator admin , Command command );
|
||||
|
||||
|
||||
protected abstract CommandResponse insufficientPrivileges( Administrator admin );
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.su;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.su.ViewAdministratorCommand;
|
||||
import com.deepclone.lw.cmd.admin.su.ViewAdministratorResponse;
|
||||
import com.deepclone.lw.interfaces.admin.Administration;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.sqld.admin.AdminRecord;
|
||||
|
||||
|
||||
|
||||
public class ViewAdministratorCommandDelegateBean
|
||||
extends SUExistingOperation
|
||||
{
|
||||
private Administration administration;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAdministration( Administration administration )
|
||||
{
|
||||
this.administration = administration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ViewAdministratorCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected CommandResponse handleCommand( Administrator admin , Command cParam )
|
||||
{
|
||||
ViewAdministratorCommand command = (ViewAdministratorCommand) cParam;
|
||||
AdminRecord record = this.administration.getAdmin( command.getIdentifier( ) );
|
||||
if ( record == null ) {
|
||||
return this.adminNotFound( admin );
|
||||
}
|
||||
return new ViewAdministratorResponse( admin , this.convertAdministrator( record ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.tick;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.tick.SetTaskStatusCommand;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.sys.TickerManager;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class SetTaskStatusCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private TickerManager manager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setManager( TickerManager manager )
|
||||
{
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return SetTaskStatusCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.TICK ) ) {
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
SetTaskStatusCommand command = (SetTaskStatusCommand) cParam;
|
||||
switch ( command.getNewStatus( ) ) {
|
||||
case RUNNING:
|
||||
this.manager.startTask( admin.getId( ) , command.getTask( ) );
|
||||
break;
|
||||
case STOPPED:
|
||||
this.manager.stopTask( admin.getId( ) , command.getTask( ) );
|
||||
break;
|
||||
case AUTO:
|
||||
this.manager.setTaskStart( admin.getId( ) , command.getTask( ) , command.getDelay( ) );
|
||||
break;
|
||||
}
|
||||
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.tick;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.tick.TickerStatusCommand;
|
||||
import com.deepclone.lw.cmd.admin.tick.TickerStatusResponse;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.sys.Ticker;
|
||||
import com.deepclone.lw.interfaces.sys.TickerManager;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class TickerStatusCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private Ticker ticker;
|
||||
private TickerManager manager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setTicker( Ticker ticker )
|
||||
{
|
||||
this.ticker = ticker;
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setManager( TickerManager manager )
|
||||
{
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return TickerStatusCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.TICK ) ) {
|
||||
return new TickerStatusResponse( admin );
|
||||
}
|
||||
return new TickerStatusResponse( admin , !this.ticker.isActive( ) , this.manager.getTasks( ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.tick;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.tick.ToggleTickerCommand;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.sys.Ticker;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class ToggleTickerCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private Ticker ticker;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setTicker( Ticker ticker )
|
||||
{
|
||||
this.ticker = ticker;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ToggleTickerCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
if ( this.getAdministrator( session ).hasPrivilege( Privileges.TICK ) ) {
|
||||
if ( this.ticker.isActive( ) ) {
|
||||
this.ticker.pause( );
|
||||
} else {
|
||||
this.ticker.unpause( );
|
||||
}
|
||||
}
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.users;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.users.GiveCreditsCommand;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
|
||||
|
||||
|
||||
public class GiveCreditsCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accounts;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccounts( AccountManagement accounts )
|
||||
{
|
||||
this.accounts = accounts;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return GiveCreditsCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.USER ) ) {
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
int credits = ( (GiveCreditsCommand) command ).getCredits( );
|
||||
if ( credits > 0 ) {
|
||||
int id = ( (GiveCreditsCommand) command ).getId( );
|
||||
this.accounts.giveCredits( admin , id , credits );
|
||||
}
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.users;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.users.AccountStatus;
|
||||
import com.deepclone.lw.cmd.admin.users.ListAccountsCommand;
|
||||
import com.deepclone.lw.cmd.admin.users.ListAccountsResponse;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ListAccountsCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accounts;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccounts( AccountManagement accounts )
|
||||
{
|
||||
this.accounts = accounts;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ListAccountsCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.USER ) ) {
|
||||
return new ListAccountsResponse( admin );
|
||||
}
|
||||
|
||||
AccountStatus status = ( (ListAccountsCommand) cParam ).getStatus( );
|
||||
boolean online = ( (ListAccountsCommand) cParam ).isOnline( );
|
||||
return new ListAccountsResponse( admin , status , online , this.accounts.listAccounts( status , online ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.users;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.users.ListSessionsCommand;
|
||||
import com.deepclone.lw.cmd.admin.users.ListSessionsResponse;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ListSessionsCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private AccountManagement accounts;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccounts( AccountManagement accounts )
|
||||
{
|
||||
this.accounts = accounts;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ListSessionsCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.USER ) ) {
|
||||
return new ListSessionsResponse( admin );
|
||||
}
|
||||
|
||||
return new ListSessionsResponse( admin , this.accounts
|
||||
.viewSessions( ( (ListSessionsCommand) command ).getId( ) ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.deepclone.lw.beans.user.admin.main.users;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.admin.common.AdminOperation;
|
||||
import com.deepclone.lw.beans.user.admin.main.AdminCommandsBean;
|
||||
import com.deepclone.lw.cmd.admin.adata.Administrator;
|
||||
import com.deepclone.lw.cmd.admin.adata.Privileges;
|
||||
import com.deepclone.lw.cmd.admin.users.AccountViewEntry;
|
||||
import com.deepclone.lw.cmd.admin.users.ViewAccountCommand;
|
||||
import com.deepclone.lw.cmd.admin.users.ViewAccountResponse;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ViewAccountCommandDelegateBean
|
||||
extends AdminOperation
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accounts;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccounts( AccountManagement accounts )
|
||||
{
|
||||
this.accounts = accounts;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return AdminCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ViewAccountCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
Administrator admin = this.getAdministrator( session );
|
||||
if ( !admin.hasPrivilege( Privileges.USER ) ) {
|
||||
return new ViewAccountResponse( admin );
|
||||
}
|
||||
|
||||
AccountViewEntry account = this.accounts.getAccountView( ( (ViewAccountCommand) command ).getId( ) );
|
||||
return new ViewAccountResponse( admin , account );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
package com.deepclone.lw.beans.user.ext;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.cmd.MailError;
|
||||
import com.deepclone.lw.cmd.PasswordError;
|
||||
import com.deepclone.lw.cmd.ext.CreateAccountCommand;
|
||||
import com.deepclone.lw.cmd.ext.CreateAccountResponse;
|
||||
import com.deepclone.lw.interfaces.acm.AccountMailException;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.i18n.TranslationException;
|
||||
import com.deepclone.lw.interfaces.i18n.Translator;
|
||||
import com.deepclone.lw.interfaces.mailer.MailerException;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
import com.deepclone.lw.utils.Password;
|
||||
|
||||
|
||||
|
||||
public class AccountCreationCommandDelegateBean
|
||||
extends LanguageListRequired
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private int minPasswordStrength = 10;
|
||||
private AccountManagement accountManagement;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setTranslator( Translator translator )
|
||||
{
|
||||
this.translator = translator;
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManagement( AccountManagement accountManagement )
|
||||
{
|
||||
this.accountManagement = accountManagement;
|
||||
}
|
||||
|
||||
|
||||
public void setMinPasswordStrength( int strength )
|
||||
{
|
||||
this.minPasswordStrength = strength;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return ExternalSessionDefinerBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return CreateAccountCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
CreateAccountCommand command = (CreateAccountCommand) cParam;
|
||||
String temp , tempConf;
|
||||
|
||||
// Check mail addresses
|
||||
EmailAddress address = null;
|
||||
MailError mailError = null;
|
||||
temp = command.getMail( );
|
||||
tempConf = command.getMailConfirm( );
|
||||
if ( temp == null || temp.trim( ).equals( "" ) ) {
|
||||
mailError = MailError.EMPTY;
|
||||
} else if ( !temp.equals( tempConf ) ) {
|
||||
mailError = MailError.MISMATCH;
|
||||
} else {
|
||||
address = new EmailAddress( temp );
|
||||
if ( !address.isValid( ) ) {
|
||||
mailError = MailError.INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
// Check passwords
|
||||
Password password = null;
|
||||
PasswordError passError = null;
|
||||
temp = command.getPassword( );
|
||||
tempConf = command.getPasswordConfirm( );
|
||||
if ( temp == null || temp.trim( ).equals( "" ) ) {
|
||||
passError = PasswordError.EMPTY;
|
||||
} else if ( !temp.equals( tempConf ) ) {
|
||||
passError = PasswordError.MISMATCH;
|
||||
} else {
|
||||
password = new Password( temp );
|
||||
if ( password.getStrength( ) < this.minPasswordStrength ) {
|
||||
passError = PasswordError.TOO_WEAK;
|
||||
}
|
||||
}
|
||||
|
||||
// Return error response if necessary at this point
|
||||
if ( passError != null || mailError != null ) {
|
||||
return this.accountValidationError( command , passError , mailError );
|
||||
}
|
||||
|
||||
return this.createAccount( address , password , command.getLanguage( ) );
|
||||
}
|
||||
|
||||
|
||||
private CreateAccountResponse createAccount( EmailAddress address , Password password , String language )
|
||||
{
|
||||
try {
|
||||
this.accountManagement.createAccount( address , password , language );
|
||||
} catch ( TranslationException e ) {
|
||||
return this.accountCreationError( address.getAddress( ) , null , null );
|
||||
} catch ( AccountMailException e ) {
|
||||
return this.accountCreationError( address.getAddress( ) , MailError.IN_USE , language );
|
||||
} catch ( MailerException e ) {
|
||||
return this.accountCreationError( address.getAddress( ) , MailError.SEND_FAIL , language );
|
||||
}
|
||||
return new CreateAccountResponse( address.getAddress( ) , language );
|
||||
}
|
||||
|
||||
|
||||
private CreateAccountResponse accountValidationError( CreateAccountCommand command , PasswordError pError ,
|
||||
MailError mError )
|
||||
{
|
||||
return new CreateAccountResponse( command.getMail( ) , command.getMailConfirm( ) , pError , mError , command
|
||||
.getLanguage( ) , this.getSupportedLanguages( ) );
|
||||
}
|
||||
|
||||
|
||||
private CreateAccountResponse accountCreationError( String address , MailError mError , String language )
|
||||
{
|
||||
return new CreateAccountResponse( address , address , null , mError , language , this.getSupportedLanguages( ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package com.deepclone.lw.beans.user.ext;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.cmd.ext.ConfirmPasswordRecoveryCommand;
|
||||
import com.deepclone.lw.cmd.ext.ConfirmPasswordRecoveryResponse;
|
||||
import com.deepclone.lw.cmd.ext.RequestPasswordRecoveryResponse;
|
||||
import com.deepclone.lw.cmd.ext.ConfirmPasswordRecoveryResponse.PasswordRecoveryStatus;
|
||||
import com.deepclone.lw.cmd.ext.RequestPasswordRecoveryResponse.PasswordRecoveryRequestStatus;
|
||||
import com.deepclone.lw.interfaces.acm.AccountMailException;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.acm.PasswordProhibitedException;
|
||||
import com.deepclone.lw.interfaces.acm.PasswordRecoveryException;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
import com.deepclone.lw.utils.Password;
|
||||
|
||||
|
||||
|
||||
public class ConfPwdRecoveryCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accountManagement;
|
||||
private int minPasswordStrength = 10;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManagement( AccountManagement accountManagement )
|
||||
{
|
||||
this.accountManagement = accountManagement;
|
||||
}
|
||||
|
||||
|
||||
public void setMinPasswordStrength( int strength )
|
||||
{
|
||||
this.minPasswordStrength = strength;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return ExternalSessionDefinerBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ConfirmPasswordRecoveryCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
ConfirmPasswordRecoveryCommand command = (ConfirmPasswordRecoveryCommand) cParam;
|
||||
EmailAddress address = new EmailAddress( command.getMailAddress( ) );
|
||||
if ( !address.isValid( ) ) {
|
||||
return new ConfirmPasswordRecoveryResponse( PasswordRecoveryStatus.INVALID_MAIL );
|
||||
}
|
||||
if ( !command.getPassword( ).equals( command.getPasswordConfirm( ) ) ) {
|
||||
return new ConfirmPasswordRecoveryResponse( PasswordRecoveryStatus.MISMATCH_PASSWORD );
|
||||
}
|
||||
|
||||
Password pwd = new Password( command.getPassword( ) );
|
||||
if ( pwd.getStrength( ) < this.minPasswordStrength ) {
|
||||
return new ConfirmPasswordRecoveryResponse( PasswordRecoveryStatus.WEAK_PASSWORD );
|
||||
}
|
||||
|
||||
String token = command.getToken( );
|
||||
try {
|
||||
this.accountManagement.recoverPassword( address , token , pwd );
|
||||
} catch ( AccountMailException e ) {
|
||||
return new ConfirmPasswordRecoveryResponse( PasswordRecoveryStatus.NOT_FOUND );
|
||||
} catch ( PasswordRecoveryException e ) {
|
||||
if ( e.statusProblem ) {
|
||||
return new RequestPasswordRecoveryResponse( PasswordRecoveryRequestStatus.ACCOUNT_STATUS );
|
||||
}
|
||||
return new ConfirmPasswordRecoveryResponse( PasswordRecoveryStatus.NOT_FOUND );
|
||||
} catch ( PasswordProhibitedException e ) {
|
||||
return new ConfirmPasswordRecoveryResponse( PasswordRecoveryStatus.PROHIBITED );
|
||||
}
|
||||
|
||||
return new ConfirmPasswordRecoveryResponse( PasswordRecoveryStatus.OK );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
package com.deepclone.lw.beans.user.ext;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.cmd.MaintenanceResponse;
|
||||
import com.deepclone.lw.cmd.admin.users.SessionTerminationType;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.session.SessionManager;
|
||||
import com.deepclone.lw.interfaces.session.SessionTypeDefiner;
|
||||
import com.deepclone.lw.interfaces.sys.MaintenanceData;
|
||||
import com.deepclone.lw.interfaces.sys.SystemStatus;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.SessionCommandException;
|
||||
import com.deepclone.lw.session.SessionStateException;
|
||||
|
||||
|
||||
|
||||
public class ExternalSessionDefinerBean
|
||||
extends SessionCommandHandler
|
||||
implements SessionTypeDefiner
|
||||
{
|
||||
|
||||
private SystemStatus systemStatus;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setSessionManager( SessionManager manager )
|
||||
{
|
||||
manager.registerSessionType( this );
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setSystemStatus( SystemStatus systemStatus )
|
||||
{
|
||||
this.systemStatus = systemStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName( )
|
||||
{
|
||||
return "ext";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAuthenticated( ServerSession session )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getState( ServerSession session )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initialise( ServerSession session )
|
||||
{
|
||||
// EMPTY
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void authenticate( ServerSession session , String identifier , String sha1Hash , String md5Hash )
|
||||
throws SessionStateException
|
||||
{
|
||||
throw new SessionStateException( );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
throws SessionStateException , SessionCommandException
|
||||
{
|
||||
try {
|
||||
// Check maintenance
|
||||
MaintenanceData mData = this.systemStatus.checkMaintenance( );
|
||||
if ( mData != null ) {
|
||||
return new MaintenanceResponse( mData.start , mData.end , mData.reason );
|
||||
}
|
||||
|
||||
return this.executeDelegate( session , command );
|
||||
} finally {
|
||||
session.terminate( );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void terminate( ServerSession session , SessionTerminationType reason )
|
||||
{
|
||||
// EMPTY
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.deepclone.lw.beans.user.ext;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.deepclone.lw.interfaces.i18n.Translator;
|
||||
import com.deepclone.lw.interfaces.i18n.UnknownLanguageException;
|
||||
|
||||
|
||||
|
||||
abstract class LanguageListRequired
|
||||
{
|
||||
protected Translator translator;
|
||||
|
||||
|
||||
protected Map< String , String > getSupportedLanguages( )
|
||||
{
|
||||
Map< String , String > result = new HashMap< String , String >( );
|
||||
for ( String lId : this.translator.getSupportedLanguages( ) ) {
|
||||
try {
|
||||
result.put( lId , this.translator.getLanguageName( lId ) );
|
||||
} catch ( UnknownLanguageException e ) {
|
||||
// EMPTY
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.deepclone.lw.beans.user.ext;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.cmd.ext.ListLanguagesCommand;
|
||||
import com.deepclone.lw.cmd.ext.ListLanguagesResponse;
|
||||
import com.deepclone.lw.interfaces.i18n.Translator;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ListLanguagesCommandDelegateBean
|
||||
extends LanguageListRequired
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setTranslator( Translator translator )
|
||||
{
|
||||
this.translator = translator;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return ExternalSessionDefinerBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ListLanguagesCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
return new ListLanguagesResponse( this.getSupportedLanguages( ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.deepclone.lw.beans.user.ext;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.cmd.ext.RequestPasswordRecoveryCommand;
|
||||
import com.deepclone.lw.cmd.ext.RequestPasswordRecoveryResponse;
|
||||
import com.deepclone.lw.cmd.ext.RequestPasswordRecoveryResponse.PasswordRecoveryRequestStatus;
|
||||
import com.deepclone.lw.interfaces.acm.AccountMailException;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.acm.PasswordRecoveryException;
|
||||
import com.deepclone.lw.interfaces.mailer.MailerException;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class ReqPwdRecoveryCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accountManagement;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManagement( AccountManagement accountManagement )
|
||||
{
|
||||
this.accountManagement = accountManagement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return ExternalSessionDefinerBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return RequestPasswordRecoveryCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
RequestPasswordRecoveryCommand command = (RequestPasswordRecoveryCommand) cParam;
|
||||
EmailAddress address = new EmailAddress( command.getMailAddress( ) );
|
||||
if ( !address.isValid( ) ) {
|
||||
return new RequestPasswordRecoveryResponse( PasswordRecoveryRequestStatus.INVALID_INPUT );
|
||||
}
|
||||
|
||||
try {
|
||||
this.accountManagement.requestPasswordRecovery( address );
|
||||
} catch ( AccountMailException e ) {
|
||||
return new RequestPasswordRecoveryResponse( PasswordRecoveryRequestStatus.ACCOUNT_NOT_FOUND );
|
||||
} catch ( MailerException e ) {
|
||||
return new RequestPasswordRecoveryResponse( PasswordRecoveryRequestStatus.MAIL_ERROR );
|
||||
} catch ( PasswordRecoveryException e ) {
|
||||
if ( e.statusProblem ) {
|
||||
return new RequestPasswordRecoveryResponse( PasswordRecoveryRequestStatus.ACCOUNT_STATUS );
|
||||
}
|
||||
return new RequestPasswordRecoveryResponse( PasswordRecoveryRequestStatus.RECOVERY_IN_PROGRESS );
|
||||
}
|
||||
|
||||
return new RequestPasswordRecoveryResponse( PasswordRecoveryRequestStatus.OK );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.deepclone.lw.beans.user.player;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.cmd.player.account.BanDetailsCommand;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class BanDetailsCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
private AccountManagement manager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement manager )
|
||||
{
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return BannedSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return BanDetailsCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command command )
|
||||
{
|
||||
EmailAddress address = new EmailAddress( session.get( "authenticationToken" , String.class ) );
|
||||
return this.manager.getBanDetails( address );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.deepclone.lw.beans.user.player;
|
||||
|
||||
|
||||
public class BannedSubTypeBean
|
||||
extends PlayerSessionSubType
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getName( )
|
||||
{
|
||||
return "banned";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.deepclone.lw.beans.user.player;
|
||||
|
||||
|
||||
public class DisabledSubTypeBean
|
||||
extends PlayerSessionSubType
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getName( )
|
||||
{
|
||||
return "disabled";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.deepclone.lw.beans.user.player;
|
||||
|
||||
|
||||
public class GameSubTypeBean
|
||||
extends PlayerSessionSubType
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getName( )
|
||||
{
|
||||
return "game";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.deepclone.lw.beans.user.player;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.cmd.player.account.GetLanguageCommand;
|
||||
import com.deepclone.lw.cmd.player.account.GetLanguageResponse;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.sqld.accounts.Account;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class GetLanguageCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
|
||||
{
|
||||
private AccountManagement manager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement manager )
|
||||
{
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return GetLanguageCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return PlayerCommonCommandsBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
EmailAddress addr = new EmailAddress( session.get( "authenticationToken" , String.class ) );
|
||||
Account accnt = this.manager.getAccount( addr );
|
||||
return new GetLanguageResponse( accnt.getLanguage( ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.deepclone.lw.beans.user.player;
|
||||
|
||||
|
||||
public class PlayerCommonCommandsBean
|
||||
extends PlayerSessionSubType
|
||||
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getName( )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
package com.deepclone.lw.beans.user.player;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.StatefulSessionTypeDefiner;
|
||||
import com.deepclone.lw.cmd.admin.users.AccountStatus;
|
||||
import com.deepclone.lw.cmd.admin.users.SessionTerminationType;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.acm.AccountSession;
|
||||
import com.deepclone.lw.interfaces.game.EmpireManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.session.SessionManager;
|
||||
import com.deepclone.lw.interfaces.sys.MaintenanceData;
|
||||
import com.deepclone.lw.interfaces.sys.SystemStatus;
|
||||
import com.deepclone.lw.sqld.accounts.Account;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class PlayerSessionDefinerBean
|
||||
extends StatefulSessionTypeDefiner
|
||||
{
|
||||
private SystemStatus systemStatus;
|
||||
private AccountManagement accountManagement;
|
||||
private EmpireManagement empireManagement;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setSystemStatus( SystemStatus systemStatus )
|
||||
{
|
||||
this.systemStatus = systemStatus;
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManagement( AccountManagement accountManagement )
|
||||
{
|
||||
this.accountManagement = accountManagement;
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setEmpireManagement( EmpireManagement empireManagement )
|
||||
{
|
||||
this.empireManagement = empireManagement;
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setSessionManager( SessionManager manager )
|
||||
{
|
||||
manager.registerSessionType( this );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName( )
|
||||
{
|
||||
return "player";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initialise( ServerSession session )
|
||||
{
|
||||
// EMPTY
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getSessionType( ServerSession session )
|
||||
{
|
||||
// If the system is under maintenance, do not check
|
||||
MaintenanceData mData = this.systemStatus.checkMaintenance( );
|
||||
if ( mData != null ) {
|
||||
return this.getState( session );
|
||||
}
|
||||
|
||||
// Get account status
|
||||
Account account = this.accountManagement.restoreSession( session.get( "sessionId" , Long.class ) );
|
||||
if ( account == null ) {
|
||||
session.terminate( SessionTerminationType.GONE );
|
||||
return null;
|
||||
}
|
||||
AccountStatus status = account.getStatus( );
|
||||
|
||||
switch ( status ) {
|
||||
case ACTIVE:
|
||||
case QUITTING:
|
||||
case START_VACATION:
|
||||
case VACATION:
|
||||
session.put( "vacation" , (Boolean) ( status == AccountStatus.VACATION ) );
|
||||
this.updateEmpireId( session );
|
||||
return "game";
|
||||
}
|
||||
|
||||
session.put( "empireId" , null );
|
||||
switch ( status ) {
|
||||
case UNCONFIRMED:
|
||||
case REACTIVATING:
|
||||
return "validation";
|
||||
case BANNED:
|
||||
return "banned";
|
||||
case DISABLED:
|
||||
return "disabled";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void updateEmpireId( ServerSession session )
|
||||
{
|
||||
if ( session.get( "empireId" , Integer.class ) != null ) {
|
||||
return;
|
||||
}
|
||||
session.put( "empireId" , this.empireManagement.getEmpireId( this.getPlayer( session ) ) );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String initAuthToken( ServerSession session , String identifier , String sha1Hash , String md5Hash )
|
||||
{
|
||||
// If the system is under maintenance, do not check
|
||||
MaintenanceData mData = this.systemStatus.checkMaintenance( );
|
||||
if ( mData != null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
EmailAddress address = new EmailAddress( identifier );
|
||||
if ( !address.isValid( ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AccountSession lResult;
|
||||
lResult = this.accountManagement.login( address , session.getChallenge( ) , sha1Hash , md5Hash , session
|
||||
.getAddress( ) , session.getClient( ) , session.getIdentifier( ) );
|
||||
if ( lResult == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// FIXME: that should not be hardcoded
|
||||
session.setExpirationDate( new Date( new Date( ).getTime( ) + 1800000L ) );
|
||||
session.put( "sessionId" , (Long) lResult.session );
|
||||
return address.getAddress( );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void terminate( ServerSession session , SessionTerminationType reason )
|
||||
{
|
||||
if ( !this.isAuthenticated( session ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.accountManagement.logout( session.get( "sessionId" , Long.class ) , reason );
|
||||
}
|
||||
|
||||
|
||||
private EmailAddress getPlayer( ServerSession session )
|
||||
{
|
||||
return new EmailAddress( this.getAuthToken( session ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.deepclone.lw.beans.user.player;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredSubTypeDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.abst.StatefulSessionTypeDefiner;
|
||||
import com.deepclone.lw.cmd.MaintenanceResponse;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.interfaces.sys.MaintenanceData;
|
||||
import com.deepclone.lw.interfaces.sys.SystemStatus;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.SessionCommandException;
|
||||
|
||||
|
||||
|
||||
abstract class PlayerSessionSubType
|
||||
extends SessionCommandHandler
|
||||
implements AutowiredSubTypeDelegate
|
||||
{
|
||||
|
||||
private SystemStatus systemStatus;
|
||||
|
||||
|
||||
public void setSystemStatus( SystemStatus systemStatus )
|
||||
{
|
||||
this.systemStatus = systemStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final Class< ? extends StatefulSessionTypeDefiner > getSessionType( )
|
||||
{
|
||||
return PlayerSessionDefinerBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final CommandResponse execute( ServerSession session , Command command )
|
||||
throws SessionCommandException
|
||||
{
|
||||
MaintenanceData mData = this.systemStatus.checkMaintenance( );
|
||||
if ( mData != null ) {
|
||||
return new MaintenanceResponse( mData.start , mData.end , mData.reason );
|
||||
}
|
||||
//FIXME: that should not be hardcoded
|
||||
session.setExpirationDate( new Date( new Date( ).getTime( ) + 1800000L ) );
|
||||
return this.executeDelegate( session , command );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.deepclone.lw.beans.user.player;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.cmd.player.account.AccountReactivationCommand;
|
||||
import com.deepclone.lw.cmd.player.account.AccountReactivationResponse;
|
||||
import com.deepclone.lw.interfaces.acm.AccountMailException;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.mailer.MailerException;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class ReactivateCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
|
||||
{
|
||||
private AccountManagement manager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement manager )
|
||||
{
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return AccountReactivationCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return DisabledSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
String address = session.get( "authenticationToken" , String.class );
|
||||
boolean rv;
|
||||
try {
|
||||
this.manager.reactivateAccount( new EmailAddress( address ) );
|
||||
rv = true;
|
||||
} catch ( AccountMailException e ) {
|
||||
rv = false;
|
||||
} catch ( MailerException e ) {
|
||||
rv = false;
|
||||
}
|
||||
return new AccountReactivationResponse( address , rv );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
package com.deepclone.lw.beans.user.player;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.ObjectNameValidatorBean;
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.cmd.ObjectNameError;
|
||||
import com.deepclone.lw.cmd.player.account.AccountValidationCommand;
|
||||
import com.deepclone.lw.cmd.player.account.AccountValidationResponse;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.sqld.accounts.ValidationResult;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class ValidationCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement manager;
|
||||
private ObjectNameValidatorBean validator;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement manager )
|
||||
{
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setObjectNameValidator( ObjectNameValidatorBean validator )
|
||||
{
|
||||
this.validator = validator;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return ValidationSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return AccountValidationCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
AccountValidationCommand command = (AccountValidationCommand) cParam;
|
||||
EmailAddress address = new EmailAddress( session.get( "authenticationToken" , String.class ) );
|
||||
|
||||
if ( command.isInitialisation( ) ) {
|
||||
return new AccountValidationResponse( this.manager.getEmpireNames( address ) );
|
||||
}
|
||||
|
||||
AccountValidationResponse vResponse;
|
||||
|
||||
// Validate empire / planet names
|
||||
vResponse = this.validateNames( command , address );
|
||||
if ( vResponse != null ) {
|
||||
return vResponse;
|
||||
}
|
||||
|
||||
// Actual validation / game registration
|
||||
ValidationResult result;
|
||||
result = this.manager.validateAccount( address , command.getToken( ) , command.getEmpire( ) , command
|
||||
.getPlanet( ) );
|
||||
|
||||
if ( result.isError( ) ) {
|
||||
return this.makeError( command , address , result );
|
||||
}
|
||||
|
||||
return new AccountValidationResponse( );
|
||||
}
|
||||
|
||||
|
||||
private AccountValidationResponse validateNames( AccountValidationCommand command , EmailAddress address )
|
||||
{
|
||||
ObjectNameError eOne = this.validator.validate( command.getEmpire( ) );
|
||||
ObjectNameError pOne = this.validator.validate( command.getPlanet( ) );
|
||||
if ( eOne == null && pOne == null ) {
|
||||
return null;
|
||||
}
|
||||
return this.makeError( command , address , false , eOne , pOne );
|
||||
}
|
||||
|
||||
|
||||
private CommandResponse makeError( AccountValidationCommand command , EmailAddress address , ValidationResult result )
|
||||
{
|
||||
ObjectNameError eOne = null , pOne = null;
|
||||
|
||||
switch ( result.getEmpireError( ) ) {
|
||||
case 1:
|
||||
eOne = ObjectNameError.BANNED;
|
||||
break;
|
||||
case 2:
|
||||
eOne = ObjectNameError.UNAVAILABLE;
|
||||
break;
|
||||
}
|
||||
|
||||
switch ( result.getPlanetError( ) ) {
|
||||
case 1:
|
||||
pOne = ObjectNameError.BANNED;
|
||||
break;
|
||||
case 2:
|
||||
pOne = ObjectNameError.UNAVAILABLE;
|
||||
break;
|
||||
}
|
||||
|
||||
return this.makeError( command , address , ( result.getAccountError( ) != 0 ) , eOne , pOne );
|
||||
}
|
||||
|
||||
|
||||
private AccountValidationResponse makeError( AccountValidationCommand command , EmailAddress address ,
|
||||
boolean wrongToken , ObjectNameError empireError , ObjectNameError planetError )
|
||||
{
|
||||
return new AccountValidationResponse( this.manager.getEmpireNames( address ) , command.getToken( ) , command
|
||||
.getEmpire( ) , command.getPlanet( ) , wrongToken , empireError , planetError );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.deepclone.lw.beans.user.player;
|
||||
|
||||
|
||||
public class ValidationSubTypeBean
|
||||
extends PlayerSessionSubType
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getName( )
|
||||
{
|
||||
return "validation";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.deepclone.lw.beans.user.player.account;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
|
||||
import com.deepclone.lw.cmd.player.account.CancelQuitCommand;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class CancelQuitCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accountManager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement accountManager )
|
||||
{
|
||||
this.accountManager = accountManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return GameSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return CancelQuitCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
EmailAddress address = new EmailAddress( session.get( "authenticationToken" , String.class ) );
|
||||
this.accountManager.cancelQuit( address );
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.deepclone.lw.beans.user.player.account;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
|
||||
import com.deepclone.lw.cmd.CreateAuthChallengeCommand;
|
||||
import com.deepclone.lw.cmd.CreateAuthChallengeResponse;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.RandomStringGenerator;
|
||||
|
||||
|
||||
|
||||
public class CreateAuthChallengeCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private RandomStringGenerator challengeGenerator;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
@Qualifier( "authChallenges" )
|
||||
public void setChallangeGenerator( RandomStringGenerator rsg )
|
||||
{
|
||||
this.challengeGenerator = rsg;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return GameSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return CreateAuthChallengeCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
String challenge = this.challengeGenerator.generate( );
|
||||
session.put( "tempChallenge" , challenge );
|
||||
return new CreateAuthChallengeResponse( challenge );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.deepclone.lw.beans.user.player.account;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
|
||||
import com.deepclone.lw.cmd.player.account.GetAccountCommand;
|
||||
import com.deepclone.lw.cmd.player.account.GetAccountResponse;
|
||||
import com.deepclone.lw.cmd.player.gdata.GamePageData;
|
||||
import com.deepclone.lw.cmd.player.gdata.account.AccountData;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.game.EmpireManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class GetAccountCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accountManager;
|
||||
private EmpireManagement empireManager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement accountManager )
|
||||
{
|
||||
this.accountManager = accountManager;
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setEmpireManager( EmpireManagement empireManager )
|
||||
{
|
||||
this.empireManager = empireManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return GameSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return GetAccountCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
EmailAddress addr = new EmailAddress( session.get( "authenticationToken" , String.class ) );
|
||||
AccountData accnt = this.accountManager.getAccountPage( addr );
|
||||
GamePageData gPage = this.empireManager.getGeneralInformation( session.get( "empireId" , Integer.class ) );
|
||||
return new GetAccountResponse( gPage , accnt );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.deepclone.lw.beans.user.player.account;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
|
||||
import com.deepclone.lw.cmd.player.account.QuitGameCommand;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class QuitGameCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accountManager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement accountManager )
|
||||
{
|
||||
this.accountManager = accountManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return GameSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return QuitGameCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
EmailAddress address = new EmailAddress( session.get( "authenticationToken" , String.class ) );
|
||||
QuitGameCommand command = (QuitGameCommand) cParam;
|
||||
this.accountManager.setQuit( address , command.getReason( ) );
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package com.deepclone.lw.beans.user.player.account;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
|
||||
import com.deepclone.lw.cmd.player.account.SetAddressCommand;
|
||||
import com.deepclone.lw.cmd.player.account.SetAddressResponse;
|
||||
import com.deepclone.lw.cmd.player.account.SetAddressResponse.AddressChangeStatus;
|
||||
import com.deepclone.lw.cmd.player.gdata.GamePageData;
|
||||
import com.deepclone.lw.cmd.player.gdata.account.AccountData;
|
||||
import com.deepclone.lw.interfaces.acm.AccountMailException;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.game.EmpireManagement;
|
||||
import com.deepclone.lw.interfaces.mailer.MailerException;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class SetAddressCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accountManager;
|
||||
private EmpireManagement empireManager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement accountManager )
|
||||
{
|
||||
this.accountManager = accountManager;
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setEmpireManager( EmpireManagement empireManager )
|
||||
{
|
||||
this.empireManager = empireManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return GameSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return SetAddressCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
EmailAddress address = new EmailAddress( session.get( "authenticationToken" , String.class ) );
|
||||
SetAddressCommand command = (SetAddressCommand) cParam;
|
||||
String challenge = session.get( "tempChallenge" , String.class );
|
||||
session.put( "tempChallenge" , null );
|
||||
|
||||
EmailAddress nAddress = null;
|
||||
AddressChangeStatus mailStatus = AddressChangeStatus.OK;
|
||||
String temp = command.getMail( );
|
||||
String tempConf = command.getMailConfirm( );
|
||||
if ( temp == null || temp.trim( ).equals( "" ) ) {
|
||||
mailStatus = AddressChangeStatus.EMPTY;
|
||||
} else if ( !temp.equals( tempConf ) ) {
|
||||
mailStatus = AddressChangeStatus.MISMATCH;
|
||||
} else {
|
||||
nAddress = new EmailAddress( temp );
|
||||
if ( !address.isValid( ) ) {
|
||||
mailStatus = AddressChangeStatus.INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
boolean authError = false;
|
||||
if ( mailStatus == AddressChangeStatus.OK ) {
|
||||
try {
|
||||
authError = !this.accountManager.setAddress( address , challenge , command.getSha1Auth( ) , command
|
||||
.getMd5Auth( ) , nAddress );
|
||||
} catch ( AccountMailException e ) {
|
||||
mailStatus = AddressChangeStatus.IN_USE;
|
||||
} catch ( MailerException e ) {
|
||||
mailStatus = AddressChangeStatus.SEND_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !authError && mailStatus == AddressChangeStatus.OK ) {
|
||||
return new SetAddressResponse( );
|
||||
}
|
||||
|
||||
AccountData accnt = this.accountManager.getAccountPage( address );
|
||||
GamePageData gPage = this.empireManager.getGeneralInformation( session.get( "empireId" , Integer.class ) );
|
||||
return new SetAddressResponse( gPage , accnt , authError , mailStatus , command.getMail( ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.deepclone.lw.beans.user.player.account;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
|
||||
import com.deepclone.lw.cmd.player.account.SetLanguageCommand;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class SetLanguageCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accountManager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement accountManager )
|
||||
{
|
||||
this.accountManager = accountManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return GameSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return SetLanguageCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
SetLanguageCommand command = (SetLanguageCommand) cParam;
|
||||
EmailAddress addr = new EmailAddress( session.get( "authenticationToken" , String.class ) );
|
||||
this.accountManager.setLanguage( addr , command.getLanguage( ) );
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package com.deepclone.lw.beans.user.player.account;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
|
||||
import com.deepclone.lw.cmd.player.account.SetPasswordCommand;
|
||||
import com.deepclone.lw.cmd.player.account.SetPasswordResponse;
|
||||
import com.deepclone.lw.cmd.player.account.SetPasswordResponse.PasswordChangeStatus;
|
||||
import com.deepclone.lw.cmd.player.gdata.GamePageData;
|
||||
import com.deepclone.lw.cmd.player.gdata.account.AccountData;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.acm.PasswordProhibitedException;
|
||||
import com.deepclone.lw.interfaces.game.EmpireManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
import com.deepclone.lw.utils.Password;
|
||||
|
||||
|
||||
|
||||
public class SetPasswordCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accountManager;
|
||||
private EmpireManagement empireManager;
|
||||
private int minPasswordStrength = 10;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement accountManager )
|
||||
{
|
||||
this.accountManager = accountManager;
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setEmpireManager( EmpireManagement empireManager )
|
||||
{
|
||||
this.empireManager = empireManager;
|
||||
}
|
||||
|
||||
|
||||
public void setMinPasswordStrength( int strength )
|
||||
{
|
||||
this.minPasswordStrength = strength;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return GameSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return SetPasswordCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
EmailAddress address = new EmailAddress( session.get( "authenticationToken" , String.class ) );
|
||||
SetPasswordCommand command = (SetPasswordCommand) cParam;
|
||||
String challenge = session.get( "tempChallenge" , String.class );
|
||||
session.put( "tempChallenge" , null );
|
||||
|
||||
PasswordChangeStatus status = PasswordChangeStatus.OK;
|
||||
Password pwd = null;
|
||||
if ( "".equals( command.getPassword( ) ) ) {
|
||||
status = PasswordChangeStatus.EMPTY;
|
||||
} else if ( !command.getPassword( ).equals( command.getPasswordConfirm( ) ) ) {
|
||||
status = PasswordChangeStatus.MISMATCH;
|
||||
} else {
|
||||
pwd = new Password( command.getPassword( ) );
|
||||
if ( pwd.getStrength( ) < this.minPasswordStrength ) {
|
||||
status = PasswordChangeStatus.TOO_WEAK;
|
||||
}
|
||||
}
|
||||
|
||||
boolean authError;
|
||||
if ( status == PasswordChangeStatus.OK ) {
|
||||
try {
|
||||
authError = !this.accountManager.setPassword( address , challenge , command.getSha1Auth( ) , command
|
||||
.getMd5Auth( ) , pwd );
|
||||
} catch ( PasswordProhibitedException e ) {
|
||||
authError = false;
|
||||
status = PasswordChangeStatus.PROHIBITED;
|
||||
}
|
||||
} else {
|
||||
authError = false;
|
||||
}
|
||||
|
||||
if ( !authError && status == PasswordChangeStatus.OK ) {
|
||||
return new SetPasswordResponse( );
|
||||
}
|
||||
|
||||
AccountData accnt = this.accountManager.getAccountPage( address );
|
||||
GamePageData gPage = this.empireManager.getGeneralInformation( session.get( "empireId" , Integer.class ) );
|
||||
return new SetPasswordResponse( gPage , accnt , authError , status );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.deepclone.lw.beans.user.player.account;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
|
||||
import com.deepclone.lw.cmd.player.account.SetPreferencesCommand;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class SetPreferencesCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
|
||||
{
|
||||
|
||||
private AccountManagement accountManager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement accountManager )
|
||||
{
|
||||
this.accountManager = accountManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return GameSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return SetPreferencesCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
SetPreferencesCommand command = (SetPreferencesCommand) cParam;
|
||||
EmailAddress address = new EmailAddress( session.get( "authenticationToken" , String.class ) );
|
||||
|
||||
if ( command.isReset( ) ) {
|
||||
this.accountManager.resetPreferences( address );
|
||||
} else {
|
||||
this.accountManager.setPreferences( address , command.getValues( ) );
|
||||
}
|
||||
|
||||
return new NullResponse( );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.deepclone.lw.beans.user.player.account;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
|
||||
import com.deepclone.lw.cmd.player.account.ToggleVacationCommand;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.NullResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class ToggleVacationCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accountManager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement accountManager )
|
||||
{
|
||||
this.accountManager = accountManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return GameSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ToggleVacationCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
EmailAddress address = new EmailAddress( session.get( "authenticationToken" , String.class ) );
|
||||
this.accountManager.toggleVacation( address );
|
||||
return new NullResponse( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.deepclone.lw.beans.user.player.account;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
|
||||
import com.deepclone.lw.cmd.player.account.ValidateSetAddressCommand;
|
||||
import com.deepclone.lw.cmd.player.account.ValidateSetAddressResponse;
|
||||
import com.deepclone.lw.cmd.player.gdata.GamePageData;
|
||||
import com.deepclone.lw.cmd.player.gdata.account.AccountData;
|
||||
import com.deepclone.lw.interfaces.acm.AccountManagement;
|
||||
import com.deepclone.lw.interfaces.game.EmpireManagement;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.utils.EmailAddress;
|
||||
|
||||
|
||||
|
||||
public class ValidateSetAddressCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private AccountManagement accountManager;
|
||||
private EmpireManagement empireManager;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setAccountManager( AccountManagement accountManager )
|
||||
{
|
||||
this.accountManager = accountManager;
|
||||
}
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setEmpireManager( EmpireManagement empireManager )
|
||||
{
|
||||
this.empireManager = empireManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return GameSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ValidateSetAddressCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
ValidateSetAddressCommand command = (ValidateSetAddressCommand) cParam;
|
||||
EmailAddress cAddress = new EmailAddress( session.get( "authenticationToken" , String.class ) );
|
||||
|
||||
if ( command.isCancel( ) ) {
|
||||
this.accountManager.cancelAddressChange( cAddress );
|
||||
} else {
|
||||
String code = command.getCode( );
|
||||
AccountData data = this.accountManager.confirmAddressChange( cAddress , code );
|
||||
if ( data.getAddress( ).equals( cAddress.getAddress( ) ) ) {
|
||||
GamePageData gPage = this.empireManager
|
||||
.getGeneralInformation( session.get( "empireId" , Integer.class ) );
|
||||
return new ValidateSetAddressResponse( gPage , data , code );
|
||||
}
|
||||
session.put( "authenticationToken" , data.getAddress( ) );
|
||||
}
|
||||
|
||||
return new ValidateSetAddressResponse( );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.deepclone.lw.beans.user.player.bt;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.deepclone.lw.beans.user.abst.AutowiredCommandDelegate;
|
||||
import com.deepclone.lw.beans.user.abst.SessionCommandHandler;
|
||||
import com.deepclone.lw.beans.user.player.GameSubTypeBean;
|
||||
import com.deepclone.lw.cmd.bt.ListBugsCommand;
|
||||
import com.deepclone.lw.cmd.bt.data.BugStatus;
|
||||
import com.deepclone.lw.interfaces.bt.PlayerBugs;
|
||||
import com.deepclone.lw.interfaces.session.ServerSession;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
|
||||
|
||||
|
||||
public class ListBugsCommandDelegateBean
|
||||
implements AutowiredCommandDelegate
|
||||
{
|
||||
|
||||
private PlayerBugs bugs;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setBugs( PlayerBugs bugs )
|
||||
{
|
||||
this.bugs = bugs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends SessionCommandHandler > getCommandHandler( )
|
||||
{
|
||||
return GameSubTypeBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< ? extends Command > getType( )
|
||||
{
|
||||
return ListBugsCommand.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ServerSession session , Command cParam )
|
||||
{
|
||||
int empireId = session.get( "empireId" , Integer.class );
|
||||
|
||||
ListBugsCommand command = (ListBugsCommand) cParam;
|
||||
long first = command.getFirst( );
|
||||
int count = command.getCount( );
|
||||
BugStatus status = command.getStatus( );
|
||||
boolean own = command.isOwnOnly( );
|
||||
|
||||
return this.bugs.getBugs( empireId , status , own , first , count );
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue