1
0
mirror of https://github.com/Rogiel/httpchannel synced 2025-12-05 23:22:51 +00:00

Implement AccountDetails object that provides account information

This commit is contained in:
2012-01-22 19:27:33 -02:00
parent 885de35de5
commit 3b06f0b9e6
33 changed files with 598 additions and 121 deletions

View File

@@ -0,0 +1,46 @@
/**
*
*/
package com.rogiel.httpchannel.service;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class AbstractAccountDetails implements AccountDetails {
protected final String username;
protected final AuthenticationService<?> service;
public AbstractAccountDetails(AuthenticationService<?> service,
String username) {
this.service = service;
this.username = username;
}
@Override
public String getUsername() {
return username;
}
@Override
public AuthenticationService<?> getService() {
return service;
}
@Override
public boolean is(Class<? extends AccountDetails> type) {
return type.isAssignableFrom(this.getClass());
}
@Override
public <T extends AccountDetails> T as(Class<T> type) {
if (!is(type))
return null;
return type.cast(this);
}
@Override
public boolean isActive() {
return true;
}
}