本文整理汇总了Java中org.apache.shiro.realm.Realm.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Realm.getName方法的具体用法?Java Realm.getName怎么用?Java Realm.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.shiro.realm.Realm
的用法示例。
在下文中一共展示了Realm.getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRealms
import org.apache.shiro.realm.Realm; //导入方法依赖的package包/类
private Collection<Realm> getRealms(Map<String, ?> instances) {
//realms and realm factory might have been created - pull them out first so we can
//initialize the securityManager:
List<Realm> realms = new ArrayList<Realm>();
//iterate over the map entries to pull out the realm factory(s):
for (Map.Entry<String, ?> entry : instances.entrySet()) {
String name = entry.getKey();
Object value = entry.getValue();
if (value instanceof RealmFactory) {
addToRealms(realms, (RealmFactory) value);
} else if (value instanceof Realm) {
Realm realm = (Realm) value;
//set the name if null:
String existingName = realm.getName();
if (existingName == null || existingName.startsWith(realm.getClass().getName())) {
if (realm instanceof Nameable) {
((Nameable) realm).setName(name);
log.debug("Applied name '{}' to Nameable realm instance {}", name, realm);
} else {
log.info("Realm does not implement the {} interface. Configured name will not be applied.",
Nameable.class.getName());
}
}
realms.add(realm);
}
}
return realms;
}
示例2: getRealm
import org.apache.shiro.realm.Realm; //导入方法依赖的package包/类
public static GwtUtilRealm getRealm() throws LogicException {
Iterator<Realm> realms = ((RealmSecurityManager) SecurityUtils.getSecurityManager()).getRealms().iterator();
Realm realm = realms.next();
if (!(realm instanceof GwtUtilRealm)) {
throw new LogicException(
"Realm " + realm.getName() + " isn't compatible to GwtUtilRealm, its type is: " + realm.getClass().getSimpleName());
}
return (GwtUtilRealm) realm;
}
示例3: bindRealm
import org.apache.shiro.realm.Realm; //导入方法依赖的package包/类
/**
* Binds the {@link Realm} to the security manager.
*
* @param realm
* the {@link Realm} to be binded
*/
protected void bindRealm(Realm realm) {
synchronized (LOCK) {
String serviceName = realm.getName();
assertServiceNameValid(serviceName);
if (!realms.containsKey(serviceName)) {
realms.put(serviceName, realm);
synchronizeRealms();
} else {
String msg = "There is already registered service with the same name: " +
serviceName;
log.warn(msg);
}
}
}
示例4: ShiroAuthProviderImpl
import org.apache.shiro.realm.Realm; //导入方法依赖的package包/类
public ShiroAuthProviderImpl(Vertx vertx, Realm realm) {
this.vertx = vertx;
this.securityManager = new DefaultSecurityManager(realm);
this.realmName = realm.getName();
}