/** * Returns a string representation of the object for error messages * and the like * @return a string representation of the object. */ public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(namespace != null ? namespace : "(anonymous)"); buffer.append(' '); buffer.append(url != null ? (url + " ") : ""); buffer.append(file != null ? file.getAbsolutePath() : ""); return buffer.toString(); }
/** * Execute the task. * @throws BuildException on error */ public void execute() throws BuildException { if (null == alias) { throw new BuildException("alias attribute must be set"); } if (null == storepass) { throw new BuildException("storepass attribute must be set"); } if (null == dname && null == expandedDname) { throw new BuildException("dname must be set"); } final StringBuffer sb = new StringBuffer(); sb.append("-genkey "); if (verbose) { sb.append("-v "); } sb.append("-alias \""); sb.append(alias); sb.append("\" "); if (null != dname) { sb.append("-dname \""); sb.append(dname); sb.append("\" "); } if (null != expandedDname) { sb.append("-dname \""); sb.append(expandedDname); sb.append("\" "); } if (null != keystore) { sb.append("-keystore \""); sb.append(keystore); sb.append("\" "); } if (null != storepass) { sb.append("-storepass \""); sb.append(storepass); sb.append("\" "); } if (null != storetype) { sb.append("-storetype \""); sb.append(storetype); sb.append("\" "); } sb.append("-keypass \""); if (null != keypass) { sb.append(keypass); } else { sb.append(storepass); } sb.append("\" "); if (null != sigalg) { sb.append("-sigalg \""); sb.append(sigalg); sb.append("\" "); } if (null != keyalg) { sb.append("-keyalg \""); sb.append(keyalg); sb.append("\" "); } if (0 < keysize) { sb.append("-keysize \""); sb.append(keysize); sb.append("\" "); } if (0 < validity) { sb.append("-validity \""); sb.append(validity); sb.append("\" "); } log("Generating Key for " + alias); final ExecTask cmd = new ExecTask(this); cmd.setExecutable(JavaEnvUtils.getJdkExecutable("keytool")); Commandline.Argument arg = cmd.createArg(); arg.setLine(sb.toString()); cmd.setFailonerror(true); cmd.setTaskName(getTaskName()); cmd.execute(); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/GenerateKey.java
Method name: String toString() Method name: void execute()
Number of AST nodes: 1 Number of AST nodes: 3
1
/**
1
/**
2
         * Returns a string representation of the object for error messages
2
     * Execute the task.
3
         * and the like
3
     * @throws BuildException on error
4
         * @return a string representation of the object.
4
     */
5
         */
5
    public void execute() throws BuildException {
6
        public String toString() {
6
7
            StringBuffer buffer = new StringBuffer();
7
        if (null == alias) {
8
            buffer.append(namespace != null ? namespace : "(anonymous)");
8
            throw new BuildException("alias attribute must be set");
9
            buffer.append(' ');
9
        }
10
            buffer.append(url != null ? (url + " ") : "");
10
11
            buffer.append(file != null ? file.getAbsolutePath() : "");
11
        if (null == storepass) {
12
            return buffer.toString();
12
            throw new BuildException("storepass attribute must be set");
13
        }
13
        }
14
15
        if (null == dname && null == expandedDname) {
16
            throw new BuildException("dname must be set");
17
        }
18
19
        final StringBuffer sb = new StringBuffer();
20
21
        sb.append("-genkey ");
22
23
        if (verbose) {
24
            sb.append("-v ");
25
        }
26
27
        sb.append("-alias \"");
28
        sb.append(alias);
29
        sb.append("\" ");
30
31
        if (null != dname) {
32
            sb.append("-dname \"");
33
            sb.append(dname);
34
            sb.append("\" ");
35
        }
36
37
        if (null != expandedDname) {
38
            sb.append("-dname \"");
39
            sb.append(expandedDname);
40
            sb.append("\" ");
41
        }
42
43
        if (null != keystore) {
44
            sb.append("-keystore \"");
45
            sb.append(keystore);
46
            sb.append("\" ");
47
        }
48
49
        if (null != storepass) {
50
            sb.append("-storepass \"");
51
            sb.append(storepass);
52
            sb.append("\" ");
53
        }
54
55
        if (null != storetype) {
56
            sb.append("-storetype \"");
57
            sb.append(storetype);
58
            sb.append("\" ");
59
        }
60
61
        sb.append("-keypass \"");
62
        if (null != keypass) {
63
            sb.append(keypass);
64
        } else {
65
            sb.append(storepass);
66
        }
67
        sb.append("\" ");
68
69
        if (null != sigalg) {
70
            sb.append("-sigalg \"");
71
            sb.append(sigalg);
72
            sb.append("\" ");
73
        }
74
75
        if (null != keyalg) {
76
            sb.append("-keyalg \"");
77
            sb.append(keyalg);
78
            sb.append("\" ");
79
        }
80
81
82
        if (0 < keysize) {
83
            sb.append("-keysize \"");
84
            sb.append(keysize);
85
            sb.append("\" ");
86
        }
87
88
        if (0 < validity) {
89
            sb.append("-validity \"");
90
            sb.append(validity);
91
            sb.append("\" ");
92
        }
93
94
        log("Generating Key for " + alias);
95
        final ExecTask cmd = new ExecTask(this);
96
        cmd.setExecutable(JavaEnvUtils.getJdkExecutable("keytool"));
97
        Commandline.Argument arg = cmd.createArg();
98
        arg.setLine(sb.toString());
99
        cmd.setFailonerror(true);
100
        cmd.setTaskName(getTaskName());
101
        cmd.execute();
102
    }
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score1.000
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    buffer.append(namespace != null ? namespace : "(anonymous)");
    2
    buffer.append(namespace != null ? namespace : "(anonymous)");
    35
    if (null != keypass)
    Differences
    Expression1Expression2Difference
    namespacenullTYPE_COMPATIBLE_REPLACEMENT
    nullkeypassTYPE_COMPATIBLE_REPLACEMENT
    buffersbVARIABLE_NAME_MISMATCH
    buffersbVARIABLE_NAME_MISMATCH
    namespacekeypassVARIABLE_NAME_MISMATCH
    "(anonymous)"storepassTYPE_COMPATIBLE_REPLACEMENT
    35
    if (null != keypass)
                                                  
    36
    sb.append(keypass);
    Differences
    Expression1Expression2Difference
    buffersbVARIABLE_NAME_MISMATCH
    namespacekeypassVARIABLE_NAME_MISMATCH
    36
    sb.append(keypass);
            
    else
                                                      
    37
    sb.append(storepass);
    Differences
    Expression1Expression2Difference
    buffersbVARIABLE_NAME_MISMATCH
    "(anonymous)"storepassTYPE_COMPATIBLE_REPLACEMENT
    37
    sb.append(storepass);
    Precondition Violations (0)
    Row Violation