{"action":"created","issue":{"url":"https://api.github.com/repos/javaee/glassfish/issues/22558","repository_url":"https://api.github.com/repos/javaee/glassfish","labels_url":"https://api.github.com/repos/javaee/glassfish/issues/22558/labels{/name}","comments_url":"https://api.github.com/repos/javaee/glassfish/issues/22558/comments","events_url":"https://api.github.com/repos/javaee/glassfish/issues/22558/events","html_url":"https://github.com/javaee/glassfish/issues/22558","id":343989602,"node_id":"MDU6SXNzdWUzNDM5ODk2MDI=","number":22558,"title":"Fail to invoke REST create-password-alias of standalone instance on DAS","user":{"login":"EckelDong","id":41615002,"node_id":"MDQ6VXNlcjQxNjE1MDAy","avatar_url":"https://avatars3.githubusercontent.com/u/41615002?v=4","gravatar_id":"","url":"https://api.github.com/users/EckelDong","html_url":"https://github.com/EckelDong","followers_url":"https://api.github.com/users/EckelDong/followers","following_url":"https://api.github.com/users/EckelDong/following{/other_user}","gists_url":"https://api.github.com/users/EckelDong/gists{/gist_id}","starred_url":"https://api.github.com/users/EckelDong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EckelDong/subscriptions","organizations_url":"https://api.github.com/users/EckelDong/orgs","repos_url":"https://api.github.com/users/EckelDong/repos","events_url":"https://api.github.com/users/EckelDong/events{/privacy}","received_events_url":"https://api.github.com/users/EckelDong/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-24T11:07:22Z","updated_at":"2018-09-17T21:02:06Z","closed_at":null,"author_association":"NONE","body":"## Environment Details\r\n* GlassFish Version (and build number): 5.0\r\n* JDK version: 1.8.0_152\r\n* OS: CentOS 7\r\n* Database:\r\n\r\n----------\r\n\r\n## Problem Description\r\nI hava A and B machines. DAS is running on machine A, and the standalone instance managed by DAS is running on machine B. When I create a password alias, I got error `Command create-password-alias failed on server instance xxx: remote failure: Cannot find aliasName in create-password-alias command model, file a bug injection failed on com.sun.enterprise.security.cli.CreatePasswordAlias.aliasName with class java.lang.String`, but it is saved to domain-passwords file of DAS, and is available to DAS only. I have to restart the standalone instance to make the new password alias available(domain-passwords rsync).\r\n\r\n## Steps to reproduce\r\nThe REST request named create-password-alias sent by DAS miss the `aliasname` or `DEFAULT` parameter, due to the `operands` variable is empty collection, and the `aliasName` property is primary\r\n\r\n```\r\npublic class CreatePasswordAlias implements AdminCommand {\r\n    final private static LocalStringManagerImpl localStrings = new LocalStringManagerImpl(CreatePasswordAlias.class);    \r\n\r\n    @Param(name=\"aliasname\", primary=true)\r\n    private String aliasName;\r\n    \r\n    @Param(name=\"aliaspassword\", password=true)\r\n    private String aliasPassword;\r\n\r\n    ....\r\n}\r\n\r\npublic class RemoteRestAdminCommand extends AdminCommandEventBrokerImpl<GfSseInboundEvent> {\r\n    .....\r\n\r\n    private ParameterMap processParams(ParameterMap opts) throws CommandException {\r\n        if (opts == null) {\r\n            opts = new ParameterMap();\r\n        }\r\n        // first, make sure we have the command model\r\n        getCommandModel();\r\n        // XXX : This is to take care of camel case from ReST calls that\r\n\t// do not go through usual CLI path\r\n        // XXX : This is not clean; this should be handled the same way\r\n\t// it is handled for incoming CLI commands\r\n        options = new ParameterMap();\r\n        for (Map.Entry<String, List<String>> o : opts.entrySet()) {\r\n            String key = o.getKey();\r\n            List<String> value = o.getValue();\r\n            options.set(key.toLowerCase(Locale.ENGLISH), value);\r\n        }\r\n        operands = options.get(\"default\");\t// \"DEFAULT\".toLowerCase()\r\n\r\n        try {\r\n            initializeDoUpload();\r\n\r\n            // if uploading, we need a payload\r\n            if (doUpload) {\r\n                outboundPayload = new RestPayloadImpl.Outbound(true);\r\n            } else {\r\n                outboundPayload = null;\r\n            }\r\n\r\n            ParameterMap result = new ParameterMap();\r\n            ParamModel operandParam = null;\r\n            for (ParamModel opt : commandModel.getParameters()) {\r\n                if (opt.getParam().primary()) {\r\n                    operandParam = opt;\r\n                    continue;\r\n                }\r\n                String paramName = opt.getName();\r\n\r\n                List<String> paramValues = new ArrayList<String>(options.get(paramName.toLowerCase(Locale.ENGLISH)));\r\n                if (!opt.getParam().alias().isEmpty() &&\r\n                        !paramName.equalsIgnoreCase(opt.getParam().alias())) {\r\n                    paramValues.addAll(options.get(opt.getParam().alias().toLowerCase(Locale.ENGLISH)));\r\n                }\r\n                if (!opt.getParam().multiple() && paramValues.size() > 1) {\r\n                    throw new CommandException(strings.get(\"tooManyOptions\",\r\n                            paramName));\r\n                }\r\n                if (paramValues.isEmpty()) {\r\n                    // perhaps it's set in the environment?\r\n                    String envValue = getFromEnvironment(paramName);\r\n                    if (envValue != null) {\r\n                        paramValues.add(envValue);\r\n                    }\r\n                }\r\n                if (paramValues.isEmpty()) {\r\n                    /*\r\n                     * Option still not set.  Note that we ignore the default\r\n                     * value and don't send it explicitly on the assumption\r\n                     * that the server will supply the default value itself.\r\n                     *\r\n                     * If the missing option is required, that's an error,\r\n                     * which should never happen here because validate()\r\n                     * should check it first.\r\n                     */\r\n                    if (!opt.getParam().optional()) {\r\n                        throw new CommandException(strings.get(\"missingOption\",\r\n                                paramName));\r\n                    }\r\n                    // optional param not set, skip it\r\n                    continue;\r\n                }\r\n                for (String paramValue : paramValues) {\r\n                    if (opt.getType() == File.class ||\r\n                            opt.getType() == File[].class) {\r\n                        addFileOption(result, paramName, paramValue);\r\n                    } else {\r\n                        result.add(paramName, paramValue);\r\n                    }\r\n                }\r\n            }\r\n\r\n            // add operands\r\n            for (String operand : operands) {\r\n                if (operandParam.getType() == File.class || operandParam.getType() == File[].class) {\r\n                    addFileOption(result, \"DEFAULT\", operand);\r\n                } else {\r\n                    result.add(\"DEFAULT\", operand);\r\n                }\r\n            }\r\n            return result;\r\n        } catch (IOException ioex) {\r\n            // possibly an error caused while reading or writing a file?\r\n            throw new CommandException(\"I/O Error\", ioex);\r\n        }\r\n    }\r\n\r\n    ....\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/javaee/glassfish/issues/comments/422170083","html_url":"https://github.com/javaee/glassfish/issues/22558#issuecomment-422170083","issue_url":"https://api.github.com/repos/javaee/glassfish/issues/22558","id":422170083,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjE3MDA4Mw==","user":{"login":"glassfishrobot","id":6104758,"node_id":"MDQ6VXNlcjYxMDQ3NTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6104758?v=4","gravatar_id":"","url":"https://api.github.com/users/glassfishrobot","html_url":"https://github.com/glassfishrobot","followers_url":"https://api.github.com/users/glassfishrobot/followers","following_url":"https://api.github.com/users/glassfishrobot/following{/other_user}","gists_url":"https://api.github.com/users/glassfishrobot/gists{/gist_id}","starred_url":"https://api.github.com/users/glassfishrobot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glassfishrobot/subscriptions","organizations_url":"https://api.github.com/users/glassfishrobot/orgs","repos_url":"https://api.github.com/users/glassfishrobot/repos","events_url":"https://api.github.com/users/glassfishrobot/events{/privacy}","received_events_url":"https://api.github.com/users/glassfishrobot/received_events","type":"User","site_admin":false},"created_at":"2018-09-17T21:02:06Z","updated_at":"2018-09-17T21:02:06Z","author_association":"CONTRIBUTOR","body":"**Closing this as this issue is migrated to** https://github.com/eclipse-ee4j/glassfish/issues/22558"}}
{"actor":{"display_login":"glassfishrobot"}}