public class Role {
protected String name;
public String getName() throws AppSecurityException{
return this.name;
}
public void setName(String name)throws AppSecurityException{
this.name = name;
}
}
public class User {
protected String name;
protected boolean value;
public String getName()throws AppSecurityException{
return this.name;
}
public void setName(String name){
this.name = name;
}
public boolean isLocked() throws AppSecurityException{
return this.value;
}
public void setLocked(boolean value) throws AppSecurityException{
this.value = value;
}
}
Yukarida goruldugu gibi burada bizim icin gerekli olan degiskenler mevcut. Simdi ise sira bir tane abstract class oluturmak olacak, burada interface`de olabilir. ama biz abstract class yaptik. Cunku metodumuzun bitanesinin icini doldurmak istiyoruz.
public abstract class SecurityManager {
public static SecurityManager getInstance(String instanceName) throws AppSecurityException {
if(("jazn").equalsIgnoreCase(instanceName)){
return new SecurityManagerJAZN();
} else{
throw new AppSecurityException("NOT FOUND");
}
}
public abstract User createUser(String username, String password);
public abstract List
public abstract User getUser(String username) throws AppSecurityException;
public abstract void dropUser(User user) throws AppSecurityException;
public abstract void dropUser(String username) throws AppSecurityException;
public abstract Role createRole(String roleName) throws AppSecurityException;
public abstract void dropRole(Role role) throws AppSecurityException;
public abstract List
public abstract Role getRole(String roleName) throws AppSecurityException;
public abstract List
public abstract List
public abstract void grantRole(User user , Role role)throws AppSecurityException;
public abstract void grantRole(Role role , Role grantee )throws AppSecurityException;
public abstract void revokeRole(User user, Role role) throws AppSecurityException;
}
Evet birtanede SecurityManager abstract clasimiz oldu. Simdi sira geldi bunlarin icini doldurmaya.
Bunun icin birtane SecurtityManagerJAZN classimizi olusturalim
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import oracle.security.jazn.JAZNContext;
import oracle.security.jazn.JAZNException;
import oracle.security.jazn.realm.Realm;
import oracle.security.jazn.realm.RealmManager;
import oracle.security.jazn.realm.RealmRole;
import oracle.security.jazn.realm.RealmUser;
import oracle.security.jazn.realm.RoleManager;
import oracle.security.jazn.realm.UserManager;
import org.accr.model.exception.AppSecurityException;
import org.accr.model.security.Role;
import org.accr.model.security.SecurityManager;
import org.accr.model.security.User;
public class SecurityManagerJAZN extends SecurityManager{
protected String realmName = "jazn.com";
public User createUser(String username, String password) throws AppSecurityException { try{
RealmManager reamMgr = JAZNContext.getRealmManager();
Realm realm = reamMgr.getRealm(realmName);
UserManager userMgr = realm.getUserManager();
RealmUser realmUser = userMgr.createUser(username,password);
User user = new User();
user.setName(realmUser.getName());
return user;
}catch(JAZNException e){
throw new AppSecurityException(e);
}
}
public List
try{
RealmManager reamMgr = JAZNContext.getRealmManager();
Realm realm = reamMgr.getRealm(realmName);
UserManager userMgr = realm.getUserManager();
Set
Iterator iter = users.iterator();
ArrayList
while(iter.hasNext()){
RealmUser realmUser = (RealmUser)iter.next();
User user = new User();
user.setName(realmUser.getName());
userList.add(user);
}
return userList;
}catch(JAZNException e){
throw new AppSecurityException(e);
}
}
public User getUser(String username) throws AppSecurityException {
try{
RealmManager reamMgr = JAZNContext.getRealmManager();
Realm realm = reamMgr.getRealm(realmName);
UserManager userMgr = realm.getUserManager();
RealmUser realmUser = userMgr.getUser(username);
User user = new User();
user.setName(realmUser.getName());
return user;
}catch(JAZNException e){
throw new AppSecurityException(e);
}
}
public void dropUser(User user) throws AppSecurityException {
String username = user.getName();
this.dropUser(username);
}
public void dropUser(String username) throws AppSecurityException {
try{
RealmManager reamMgr = JAZNContext.getRealmManager();
Realm realm = reamMgr.getRealm(realmName);
UserManager userMgr = realm.getUserManager();
userMgr.dropUser(username);
}catch(JAZNException e){
throw new AppSecurityException(e);
}
}
public Role createRole(String roleName) throws AppSecurityException{
try{
RealmManager reamMgr = JAZNContext.getRealmManager();
Realm realm = reamMgr.getRealm(realmName);
RoleManager realmMgr = realm.getRoleManager();
RealmRole realmRole = realmMgr.createRole(roleName);
Role role = new Role();
role.setName(realmRole.getName());
return role;
}catch(JAZNException e){
throw new AppSecurityException(e);
}
}
public void dropRole(Role role) throws AppSecurityException {
String roleName = role.getName();
this.dropUser(roleName);
}
public List
try{
RealmManager reamMgr = JAZNContext.getRealmManager();
Realm realm = reamMgr.getRealm(realmName);
RoleManager roleMgr = realm.getRoleManager();
Set
Iterator iter = rols.iterator();
ArrayList
while(iter.hasNext()){
RealmRole realmRole = (RealmRole)iter.next();
Role role = new Role();
role.setName(realmRole.getName());
roleList.add(role);
}
return roleList;
}catch(JAZNException e){
throw new AppSecurityException(e);
}
}
public Role getRole(String roleName) throws AppSecurityException {
try{
RealmManager reamMgr = JAZNContext.getRealmManager();
Realm realm = reamMgr.getRealm(realmName);
RoleManager roleMgr = realm.getRoleManager();
RealmRole realmRole = roleMgr.getRole(roleName);
Role role = new Role();
role.setName(realmRole.getName());
return role;
}catch(JAZNException e){
throw new AppSecurityException(e);
}
}
public void grantRole(User user, Role role) throws AppSecurityException {
try{
RealmManager realmMgr = JAZNContext.getRealmManager();
Realm realm = realmMgr.getRealm(realmName);
UserManager userMgr = realm.getUserManager();
String userName = user.getName();
RealmUser realmUser = userMgr.getUser(userName);
RoleManager roleMgr = realm.getRoleManager();
RealmRole realmRole = roleMgr.getRole(role.getName());
roleMgr.grantRole(realmUser,realmRole);
}catch(JAZNException e){
throw new AppSecurityException(e);
}
}
public void grantRole(Role role, Role grantee) throws AppSecurityException {
try{
RealmManager realmMgr = JAZNContext.getRealmManager();
Realm realm = realmMgr.getRealm(realmName);
String roleName = role.getName();
RoleManager roleMgr = realm.getRoleManager();
RealmRole realmRole = roleMgr.getRole(roleName);
RealmRole realmGrantee = roleMgr.getRole(role.getName());
roleMgr.grantRole(realmRole, realmGrantee);
}catch(JAZNException e){
throw new AppSecurityException(e);
}
}
public void revokeRole(User user, Role role) throws AppSecurityException {
try{
RealmManager realmMgr = JAZNContext.getRealmManager();
Realm realm = realmMgr.getRealm(realmName);
UserManager userMgr = realm.getUserManager();
String userName = user.getName();
RealmUser realmUser = userMgr.getUser(userName);
RoleManager roleMgr = realm.getRoleManager();
RealmRole realmRole = roleMgr.getRole(role.getName());
roleMgr.revokeRole(realmUser, realmRole);
}catch(JAZNException e){
throw new AppSecurityException(e);
}
}
public List
try{
RealmManager reamMgr = JAZNContext.getRealmManager();
Realm realm = reamMgr.getRealm(realmName);
RoleManager roleMgr = realm.getRoleManager();
UserManager userMgr = realm.getUserManager();
String userName = user.getName();
RealmUser realmUser = userMgr.getUser(userName);
Set
(realmUser,true);
Iterator
ArrayList
while(iter.hasNext()){
Role role = new Role();
role.setName(iter.next().getName());
roleList.add(role);
} return roleList;
}catch(JAZNException e){
throw new AppSecurityException(e);
}
}
public List
RealmManager reamMgr = JAZNContext.getRealmManager();
Realm realm = reamMgr.getRealm(realmName);
RoleManager roleMgr = realm.getRoleManager();
String roleName = role.getName();
RealmRole realmRole = roleMgr.getRole(roleName);
Set
Iterator
ArrayList
while(iter.hasNext()){
Role role1 = new Role();
role.setName(iter.next().getName());
roleList.add(role1);
}
return roleList;
}catch(JAZNException e){
throw new AppSecurityException(e);
}
}
}
Hey,
YanıtlaSilI keep coming to this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]ertugrulaslan.blogspot.com really contains lot of useful information. I am sure due to busy scedules we really do not get time to care about our health. Are you really serious about your weight?. Recent Scientific Research displays that almost 50% of all USA adults are either fat or weighty[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Hence if you're one of these individuals, you're not alone. In fact, most of us need to lose a few pounds once in a while to get sexy and perfect six pack abs. Now the question is how you are planning to have quick weight loss? You can easily lose with with little effort. You need to improve some of you daily habbits to achive weight loss in short span of time.
About me: I am blogger of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also health expert who can help you lose weight quickly. If you do not want to go under painful training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for fast weight loss.
The post has pгονen helpful tо us. It’s very informative
YanıtlaSiland you геally aгe clearly quite
knοwledgeаble in thiѕ area. You get eхposed my
face for you to ѵariouѕ thoughtѕ about this spеcific subject along with intriquіng,
nоtаble and strong contеnt material.
Аlso visit my homepage: buy oxycontin online
Feel free to surf my web page : buy oxycontin
These are in fact enormous ideas in on the topic of blogging.
YanıtlaSilYou have touched some fastidious things here. Any way keep up wrinting.
Also visit my web page - maleextra review
Yοuг pοst providеs verifіed necessaгy to
YanıtlaSilme. It’s very useful and you're simply clearly extremely well-informed in this field. You get opened my own face to different opinion of this specific subject matter using intriguing and sound content material.
My page ... www.marehof.nl
my website :: buy codeine
We stumbled over here different web page and thought I may as well check
YanıtlaSilthings out. I like what I see so now i am following you.
Look forward to looking over your web page again.
Review my blog; male extra review
The articlе ρгоvіdeѕ prοvеn beneficial to
YanıtlaSilme. It’s really usеful and you arе obѵiously еxtremely ωell-іnformed in this aгea.
You haѵe got opened up my personal eyes to be аble tо vaгіous vіews on
this kind of subject using intеrеsting and stгong ωrittеn content.
mу blog: viagra online
my webpage: viagra
Υour pοst ргovides pгovеn helpful tο
YanıtlaSilme. It’s really usеful аnd yοu
are naturally vеry experiеnced in this areа.
You haѵe pоpρed my fаce іn oгder to numerous vіews оn this matter uѕing іntгiguіng and rеliable articleѕ.
Heгe is mу websіte - phentermine
Thanks for finally talking about > "JAZN oracle security" < Loved it!
YanıtlaSilAlso visit my blog post news.
icemakermachine.info
Hello! Someone in my Myspace group shared this website with us so I came to give it a
YanıtlaSillook. I'm definitely enjoying the information. I'm bookmarking and
will be tweeting this to my followers! Terrific blog and brilliant style
and design.
Have a look at my webpage: provillus
Have you ever considered about adding a little bit more than just your articles?
YanıtlaSilI mean, what you say is important and everything.
But imagine if you added some great graphics or videos to
give your posts more, "pop"! Your content is excellent but with pics and video clips, this blog could certainly be one of the very best in its field.
Awesome blog!
Also visit my web page revitol skin brightener
Hello this is someωhat оf off topic but I ωas wаnting to κnow if blogѕ use WYSIWYG editors oг if you havе
YanıtlaSilto manually code ωith HТML. I'm starting a blog soon but have no coding expertise so I wanted to get advice from someone with experience. Any help would be enormously appreciated!
Visit my webpage diettolosebellyfat.webs.com
Hello great blog! Does running a blog similar to this take a lot of work?
YanıtlaSilI've virtually no expertise in coding but I was hoping to start my own blog in the near future. Anyways, if you have any suggestions or techniques for new blog owners please share. I know this is off topic however I simply had to ask. Appreciate it!
My web page ... top40lyrics.net