0N/A/**
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0N/A *
0N/A * Copyright (c) 2009 Sun Microsystems Inc. All Rights Reserved
0N/A *
0N/A * The contents of this file are subject to the terms
0N/A * of the Common Development and Distribution License
0N/A * (the License). You may not use this file except in
0N/A * compliance with the License.
0N/A *
0N/A * You can obtain a copy of the License at
0N/A * https://opensso.dev.java.net/public/CDDLv1.0.html or
0N/A * opensso/legal/CDDLv1.0.txt
0N/A * See the License for the specific language governing
0N/A * permission and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL
0N/A * Header Notice in each file and include the License file
0N/A * at opensso/legal/CDDLv1.0.txt.
0N/A * If applicable, add the following below the CDDL Header,
0N/A * with the fields enclosed by brackets [] replaced by
0N/A * your own identifying information:
0N/A * "Portions Copyrighted [year] [name of copyright owner]"
0N/A *
0N/A * $Id: FedletEncodeDecode.java,v 1.1 2009/11/12 17:30:31 exu Exp $
0N/A *
0N/A */
0N/A
0N/Apackage com.sun.identity.fedlet;
0N/A
288N/Aimport com.sun.identity.security.DecodeAction;
0N/Aimport com.sun.identity.security.EncodeAction;
0N/Aimport com.sun.identity.saml.xmlsig.PasswordDecoder;
0N/Aimport java.security.AccessController;
0N/A
0N/A
0N/A/**
0N/A * Utility that a fedlet can use to encode/decode password.
0N/A */
0N/Apublic class FedletEncodeDecode implements PasswordDecoder {
0N/A
0N/A /**
0N/A * Encodes the password.
0N/A * @param args password to be encoded.
0N/A */
0N/A public static void main(String[] args) {
0N/A if ((args == null) || (args.length != 1)) {
0N/A System.err.println("Invalid parameter.");
0N/A System.err.println("Expected parameter : <text_tobe_encoded>");
0N/A System.exit(-1);
0N/A }
0N/A
try {
System.out.println((String) AccessController.doPrivileged(
new EncodeAction(args[0])));
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
/**
* Returns decoded password.
*
* @param encodedPwd encoded password
* @return decoded password, return null if couldn't
* decode the password.
*/
public String getDecodedPassword (String encodedPwd) {
String password = (String) AccessController.doPrivileged(
new DecodeAction(encodedPwd));
return password;
}
}