static { // same properties for authZ and authZPolicy try { ContextConfig cc = ContextConfig.getInstance(ServiceNames.SVC_RM); String configFile = cc.getFilePath(ConfigDefaults.CONFIG); Map config = ConfigHelper.getConfiguration(configFile); assert config != null : "No configuration"; Map RMconfig = (Map) config.get("resourceManager"); assert RMconfig != null : "No resourceManager stanza in configuration"; dbname = (String) RMconfig.get("dbname"); assert dbname != null : "No dbname in configuration"; username = (String) RMconfig.get("username"); assert username != null : "No user name in configuration"; password = (String) RMconfig.get("password"); assert password != null : "No password in configuration"; monitor = (String) RMconfig.get("monitor"); scanInterval = Integer.valueOf((String) RMconfig.get("scanInterval")); lookAhead = Integer.valueOf((String) RMconfig.get("lookAhead")); configFile = cc.getFilePath(ServiceNames.SVC_UTILS, cc.getContext(), ConfigDefaults.CONFIG); Map utilConfig = (HashMap<String, Object>) ConfigHelper.getConfiguration(configFile); Map localDomain = (Map) utilConfig.get("localDomain"); localDomainId = (String) localDomain.get("id"); System.out.println("localDomainId is " + localDomainId); } catch (ConfigException e) { log.error("configurationException " + e.getMessage()); } }
/** * @param args arg[0] -c cmd, [1] -u loginName or -s Subject DN, [2] -p password or -i Issuer DN * [3] -C context * @throws Exception */ public static void main(String args[]) throws Exception { parseArgs(args); cc.setContext(context); cc.setServiceName(ServiceNames.SVC_AUTHN); try { cc.loadManifest(ServiceNames.SVC_AUTHN, ConfigDefaults.MANIFEST); // manifest.yaml cc.setLog4j(); } catch (ConfigException ex) { System.out.println("caught ConfigurationException " + ex.getMessage()); System.exit(-1); } String configFile = cc.getFilePath(ConfigDefaults.CONFIG); Map config = ConfigHelper.getConfiguration(configFile); assert config != null : "No configuration"; Map authN = (Map) config.get("soap"); URL host = new URL((String) authN.get("publishTo")); URL wsdl = cc.getWSDLPath(null); System.out.println("host is " + host.toString() + "wsdl is " + wsdl.toString()); AuthNClient client = AuthNClient.getClient(host, wsdl); if (cmd.equals("verifyLogin")) { System.out.println("Invoking verifyLogin..."); if (loginName == null || password == null) { parser.printHelpOn(System.out); System.exit(0); } LoginId loginId = new LoginId(); VerifyLoginReqType verifyLoginReq = new VerifyLoginReqType(); loginId.setLoginName(loginName); loginId.setPassword(password); verifyLoginReq.setLoginId(loginId); verifyLoginReq.setTransactionId("0000"); Object[] req = new Object[] {verifyLoginReq}; try { Object[] res = client.invoke("verifyLogin", req); VerifyReply reply = (VerifyReply) res[0]; SubjectAttributes subjectAttrs = reply.getSubjectAttributes(); List<AttributeType> attrs = subjectAttrs.getSubjectAttribute(); if (attrs.isEmpty()) { System.out.println("verifyLogin result= " + loginName + " has no attributes"); } else { for (AttributeType at : attrs) { System.out.println( "verifyLogin.result=" + at.getName() + " : " + at.getAttributeValue()); } } } catch (OSCARSServiceException ex) { System.out.println("OSCARSServiceException thrown; " + ex.getMessage()); ErrorReport errReport = ex.getErrorReport(); if (errReport != null) { System.out.println(errReport.toString()); } } } else if (cmd.equals("verifyDN")) { System.out.println("Invoking verifyDN..."); if (issuer == null || subject == null) { parser.printHelpOn(System.out); System.exit(0); } VerifyDNReqType verifyDNReq = new VerifyDNReqType(); DNType DNReq = new DNType(); DNReq.setSubjectDN(subject); DNReq.setIssuerDN(issuer); verifyDNReq.setTransactionId("123"); verifyDNReq.setDN(DNReq); Object[] req = new Object[] {verifyDNReq}; try { Object[] res = client.invoke("verifyDN", req); VerifyReply reply = (VerifyReply) res[0]; SubjectAttributes subjectAttrs = reply.getSubjectAttributes(); List<AttributeType> attrs = subjectAttrs.getSubjectAttribute(); if (attrs.isEmpty()) { System.out.println("verifyDN result= user has no attributes"); } else { for (AttributeType at : attrs) { System.out.println("verifyDN.result=" + at.getName() + " : " + at.getAttributeValue()); } } } catch (OSCARSServiceException ex) { System.out.println("OSCARSServiceException thrown: " + ex.getMessage()); ErrorReport errReport = ex.getErrorReport(); if (errReport != null) { System.out.println(errReport.toString()); } } } else { System.out.println("unrecognized command: " + cmd); } System.exit(0); }