use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class ServerRemoteRestAdminCommand method completeInit.
private synchronized void completeInit(final ServiceLocator habitat) {
this.habitat = habitat;
final Domain domain = habitat.getService(Domain.class);
secureAdmin = domain.getSecureAdmin();
serverEnv = habitat.getService(ServerEnvironment.class);
this.secure = SecureAdmin.Util.isEnabled(secureAdmin);
domainPasswordAliasStore = habitat.getService(DomainScopedPasswordAliasStore.class);
setInteractive(false);
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class NodeAgentConfigUpgrade method postConstruct.
@Override
public void postConstruct() {
final NodeAgents nodeAgents = domain.getNodeAgents();
if (nodeAgents == null) {
createDefaultNodeList();
return;
}
final List<NodeAgent> agList = nodeAgents.getNodeAgent();
if (agList.isEmpty()) {
createDefaultNodeList();
return;
}
try {
ConfigSupport.apply(new SingleConfigCode<Domain>() {
@Override
public Object run(Domain d) throws PropertyVetoException, TransactionFailure {
Nodes nodes = d.createChild(Nodes.class);
Transaction t = Transaction.getTransaction(d);
if (t == null)
return null;
for (NodeAgent na : agList) {
String host = null;
Node node = nodes.createChild(Node.class);
node.setName(na.getName());
node.setType("CONFIG");
JmxConnector jc = na.getJmxConnector();
if (jc != null) {
// get the properties and see if host name is specified
List<Property> agentProp = jc.getProperty();
for (Property p : agentProp) {
String name = p.getName();
if (name.equals("client-hostname")) {
// create the node with a host name
node.setNodeHost(p.getValue());
node.setInstallDir("${com.sun.aas.productRoot}");
}
}
}
nodes.getNode().add(node);
}
// Now add the builtin localhost node
createDefaultNode(d, nodes);
d.setNodes(nodes);
List<Server> serverList = servers.getServer();
if (serverList.isEmpty())
return null;
for (Server s : serverList) {
s = t.enroll(s);
s.setNodeRef(s.getNodeAgentRef());
s.setNodeAgentRef(null);
}
// remove the node-agent element by setting to null
d.setNodeAgents(null);
return null;
}
}, domain);
} catch (Exception e) {
Logger.getAnonymousLogger().log(Level.SEVERE, "Failure while upgrading node-agent from V2 to V3", e);
throw new RuntimeException(e);
}
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class UniqueResourceNameValidator method isValid.
@Override
public boolean isValid(final Resource resource, final ConstraintValidatorContext constraintValidatorContext) {
if (domain != null) {
if (resource.getParent().getParent() instanceof Domain) {
for (Resource res : domain.getResources().getResources()) {
if (resource.getIdentity().equals(res.getIdentity())) {
Class[] resourceInterfaces = resource.getClass().getInterfaces();
Class[] resInterfaces = res.getClass().getInterfaces();
for (Class resourceClass : resourceInterfaces) {
for (Class resClass : resInterfaces) {
if (resClass.isAssignableFrom(resourceClass)) {
return true;
}
}
}
return false;
}
}
}
}
return true;
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class RealmsImpl method getAnonymousUser.
public String getAnonymousUser() {
Domain domain = InjectedValues.getInstance().getHabitat().getService(Domain.class);
List<Config> configs = domain.getConfigs().getConfig();
// find the ADMIN_REALM
AuthRealm adminFileAuthRealm = null;
for (Config config : configs) {
if (config.getSecurityService() == null)
continue;
for (AuthRealm auth : config.getSecurityService().getAuthRealm()) {
if (auth.getName().equals(ADMIN_REALM)) {
adminFileAuthRealm = auth;
break;
}
}
}
if (adminFileAuthRealm == null) {
// There must always be an admin realm
throw new IllegalStateException("Cannot find admin realm");
}
// Get FileRealm class name
String fileRealmClassName = adminFileAuthRealm.getClassname();
if (!fileRealmClassName.equals(FILE_REALM_CLASSNAME)) {
// we treat this as an error and instead of throwing exception return false;
return null;
}
Property keyfileProp = adminFileAuthRealm.getProperty("file");
if (keyfileProp == null) {
throw new IllegalStateException("Cannot find property 'file'");
}
String keyFile = keyfileProp.getValue();
if (keyFile == null) {
throw new IllegalStateException("Cannot find key file");
}
String user = null;
String[] usernames = getUserNames(adminFileAuthRealm.getName());
if (usernames.length == 1) {
try {
InjectedValues.getInstance().getHabitat().getService(SecurityLifecycle.class);
WebAndEjbToJaasBridge.login(usernames[0], new char[0], ADMIN_REALM);
user = usernames[0];
} catch (final Exception e) {
//
}
}
return user;
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class ReferenceConstrainTest method doChangeToValidPool.
// @Ignore
@Test
public void doChangeToValidPool() throws TransactionFailure {
Domain domain = habitat.getService(Domain.class);
// Find JdbcResource to chenge its values
Iterator<JdbcResource> iterator = domain.getResources().getResources(JdbcResource.class).iterator();
JdbcResource jdbc = null;
while (iterator.hasNext()) {
JdbcResource res = iterator.next();
if ("__TimerPool".equals(res.getPoolName())) {
jdbc = res;
break;
}
}
assertNotNull(jdbc);
ConfigBean poolConfig = (ConfigBean) ConfigBean.unwrap(jdbc);
Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
Map<String, String> configChanges = new HashMap<String, String>();
configChanges.put("pool-name", "H2Pool");
changes.put(poolConfig, configChanges);
try {
ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
cs.apply(changes);
} catch (TransactionFailure tf) {
fail();
}
}
Aggregations