Search in sources :

Example 1 with AuthPrincipal

use of com.sun.identity.authentication.internal.AuthPrincipal in project OpenAM by OpenRock.

the class UpdateDNSAlias method main.

public static void main(String[] args) {
    if (args.length != 5) {
        System.out.println(" Usage: UpdateDNSAlias " + "<add | delete> <orgdn> <dnsalias> <userdn> <passwd>");
        System.exit(1);
    }
    String opt = args[0];
    String orgDn = args[1];
    String dnsAlias = args[2];
    if ((opt == null) || (orgDn == null) || (dnsAlias == null)) {
        debug.error("One or more parameters are null");
        System.exit(1);
    }
    try {
        String bindDN = args[3];
        String password = args[4];
        SSOTokenManager ssom = SSOTokenManager.getInstance();
        SSOToken token = ssom.createSSOToken(new AuthPrincipal(bindDN), password);
        AMStoreConnection asc = new AMStoreConnection(token);
        AMOrganization org = asc.getOrganization(orgDn);
        Set values = org.getAttribute("sunOrganizationAlias");
        HashMap map = new HashMap();
        if (opt.equalsIgnoreCase("add")) {
            if (!values.contains(dnsAlias)) {
                values.add(dnsAlias);
            }
            map.put("sunOrganizationAlias", values);
            org.setAttributes(map);
            org.store();
        } else if (opt.equalsIgnoreCase("delete")) {
            values.remove(dnsAlias);
            map.put("sunOrganizationAlias", values);
            org.setAttributes(map);
            org.store();
        } else {
            debug.error("Unknown option in AMGenerateServerID");
            System.exit(1);
        }
    } catch (Exception e) {
        debug.error("Exception occured:", e);
    }
    System.exit(0);
}
Also used : SSOTokenManager(com.iplanet.sso.SSOTokenManager) SSOToken(com.iplanet.sso.SSOToken) AMStoreConnection(com.iplanet.am.sdk.AMStoreConnection) Set(java.util.Set) HashMap(java.util.HashMap) AMOrganization(com.iplanet.am.sdk.AMOrganization) AuthPrincipal(com.sun.identity.authentication.internal.AuthPrincipal)

Example 2 with AuthPrincipal

use of com.sun.identity.authentication.internal.AuthPrincipal in project OpenAM by OpenRock.

the class AMGenerateServerID method main.

public static void main(String[] args) {
    if (args.length != 4) {
        System.out.println(" Usage: AMGenerateServerID create|delete " + "<serverurl> amadminDN amadminPassword");
        System.exit(1);
    }
    String opt = args[0];
    String serverUrl = args[1];
    try {
        String bindDN = args[2];
        String password = args[3];
        SSOTokenManager ssom = SSOTokenManager.getInstance();
        SSOToken token = ssom.createSSOToken(new AuthPrincipal(bindDN), password);
        Set servers = ServerConfiguration.getServerInfo(token);
        for (Iterator iter = servers.iterator(); iter.hasNext(); ) {
            String server = (String) iter.next();
            if (server.startsWith(serverUrl)) {
                debug.message("server already exists., exiting");
                System.exit(0);
            }
        }
        if (opt.equalsIgnoreCase("create")) {
            if (debug.messageEnabled()) {
                debug.message("New server entry:" + serverUrl);
            }
            ServerConfiguration.createServerInstance(token, serverUrl, Collections.EMPTY_SET, "");
        } else if (opt.equalsIgnoreCase("delete")) {
            if (ServerConfiguration.deleteServerInstance(token, serverUrl)) {
                debug.message("Server entry to be removed:" + serverUrl);
            } else {
                debug.message("Can not find server in server's list:" + serverUrl);
                System.exit(1);
            }
        } else {
            debug.message("Unknown option in AMGenerateServerID");
            System.exit(1);
        }
    } catch (Exception e) {
        debug.error("Exception occured:", e);
    }
}
Also used : SSOTokenManager(com.iplanet.sso.SSOTokenManager) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) Iterator(java.util.Iterator) AuthPrincipal(com.sun.identity.authentication.internal.AuthPrincipal)

Example 3 with AuthPrincipal

use of com.sun.identity.authentication.internal.AuthPrincipal in project OpenAM by OpenRock.

the class InitializeSystem method getSSOToken.

public SSOToken getSSOToken(String bindPwd) throws LoginException, InvalidAuthContextException {
    SSOToken ssoToken = null;
    String userRootSuffix = bData.getUserBaseDN();
    AuthPrincipal principal = new AuthPrincipal("cn=dsameuser,ou=DSAME Users," + userRootSuffix);
    AuthContext ac = new AuthContext(userRootSuffix, principal, bindPwd.toCharArray());
    if (ac.getLoginStatus() == AuthContext.AUTH_SUCCESS) {
        ssoToken = ac.getSSOToken();
    }
    return ssoToken;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) AuthContext(com.sun.identity.authentication.internal.AuthContext) AuthPrincipal(com.sun.identity.authentication.internal.AuthPrincipal)

Example 4 with AuthPrincipal

use of com.sun.identity.authentication.internal.AuthPrincipal in project OpenAM by OpenRock.

the class Bootstrap method getSSOToken.

private static SSOToken getSSOToken(String basedn, String bindUser, String bindPwd) throws LoginException, InvalidAuthContextException {
    SSOToken ssoToken = null;
    AuthPrincipal principal = new AuthPrincipal(bindUser);
    AuthContext ac = new AuthContext(basedn, principal, bindPwd.toCharArray());
    if (ac.getLoginStatus() == AuthContext.AUTH_SUCCESS) {
        ssoToken = ac.getSSOToken();
    }
    return ssoToken;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) AuthContext(com.sun.identity.authentication.internal.AuthContext) AuthPrincipal(com.sun.identity.authentication.internal.AuthPrincipal)

Example 5 with AuthPrincipal

use of com.sun.identity.authentication.internal.AuthPrincipal in project OpenAM by OpenRock.

the class SMSLdapObject method initialize.

/**
     * Synchronized initialized method
     */
private synchronized void initialize() throws SMSException {
    if (initialized) {
        return;
    }
    // Obtain the I18N resource bundle & Debug
    debug = Debug.getInstance("amSMSLdap");
    AMResourceBundleCache amCache = AMResourceBundleCache.getInstance();
    bundle = amCache.getResBundle(IUMSConstants.UMS_BUNDLE_NAME, java.util.Locale.ENGLISH);
    OU_ATTR[0] = getNamingAttribute();
    O_ATTR[0] = getOrgNamingAttribute();
    String enableP = SystemProperties.get(SMSEntry.DB_PROXY_ENABLE);
    enableProxy = (enableP != null) && enableP.equalsIgnoreCase("true");
    if (debug.messageEnabled()) {
        debug.message("SMSLdapObject: proxy enable value: " + enableProxy);
    }
    try {
        if (enableProxy) {
            // Initialize the principal, used only with AMSDK
            // for proxy connections
            adminPrincipal = new AuthPrincipal((String) AccessController.doPrivileged(new AdminDNAction()));
            // Get UMS datalayer
            dlayer = DataLayer.getInstance();
            if (debug.messageEnabled()) {
                debug.message("SMSLdapObject: DataLayer instance " + "obtained.");
            }
        } else {
            // Get SM datalayer
            smdlayer = SMDataLayer.getInstance();
            if (debug.messageEnabled()) {
                debug.message("SMSLdapObject: SMDataLayer instance " + "obtained.");
            }
        }
        if ((dlayer == null) && (smdlayer == null)) {
            debug.error("SMSLdapObject: Unable to initialize LDAP");
            throw (new SMSException(IUMSConstants.UMS_BUNDLE_NAME, IUMSConstants.CONFIG_MGR_ERROR, null));
        }
        debug.message("SMSLdapObject: LDAP Initialized successfully");
        // Get connection retry parameters
        DataLayer.initConnectionParams();
        connNumRetry = DataLayer.getConnNumRetry();
        connRetryInterval = DataLayer.getConnRetryInterval();
        retryErrorCodes = DataLayer.getRetryErrorCodes();
        // Need to check if the root nodes exists. If not, create them
        String serviceDN = SMSEntry.SERVICES_RDN + SMSEntry.COMMA + getRootSuffix();
        if (!entryExists(serviceDN)) {
            Map attrs = new HashMap();
            Set attrValues = new HashSet();
            attrValues.add(SMSEntry.OC_TOP);
            attrValues.add(SMSEntry.OC_ORG_UNIT);
            attrs.put(SMSEntry.ATTR_OBJECTCLASS, attrValues);
            create(adminPrincipal, serviceDN, attrs);
        }
    } catch (Exception e) {
        // Unable to initialize (trouble!!)
        debug.error("SMSEntry: Unable to initalize(exception):", e);
        throw (new SMSException(IUMSConstants.UMS_BUNDLE_NAME, IUMSConstants.CONFIG_MGR_ERROR, null));
    }
    initialized = true;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) AdminDNAction(com.sun.identity.security.AdminDNAction) SMSException(com.sun.identity.sm.SMSException) HashMap(java.util.HashMap) AMResourceBundleCache(com.sun.identity.shared.locale.AMResourceBundleCache) AuthPrincipal(com.sun.identity.authentication.internal.AuthPrincipal) Map(java.util.Map) HashMap(java.util.HashMap) EntryNotFoundException(org.forgerock.opendj.ldap.EntryNotFoundException) NamingException(javax.naming.NamingException) SSOException(com.iplanet.sso.SSOException) LdapException(org.forgerock.opendj.ldap.LdapException) SMSException(com.sun.identity.sm.SMSException) SearchResultReferenceIOException(org.forgerock.opendj.ldap.SearchResultReferenceIOException) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

AuthPrincipal (com.sun.identity.authentication.internal.AuthPrincipal)12 SSOToken (com.iplanet.sso.SSOToken)8 SSOTokenManager (com.iplanet.sso.SSOTokenManager)5 AuthContext (com.sun.identity.authentication.internal.AuthContext)5 SSOException (com.iplanet.sso.SSOException)4 Set (java.util.Set)4 AdminDNAction (com.sun.identity.security.AdminDNAction)2 ConfiguratorException (com.sun.identity.setup.ConfiguratorException)2 SMSException (com.sun.identity.sm.SMSException)2 HashMap (java.util.HashMap)2 AMException (com.iplanet.am.sdk.AMException)1 AMOrganization (com.iplanet.am.sdk.AMOrganization)1 AMStoreConnection (com.iplanet.am.sdk.AMStoreConnection)1 DSConfigMgr (com.iplanet.services.ldap.DSConfigMgr)1 ServerInstance (com.iplanet.services.ldap.ServerInstance)1 XMLException (com.iplanet.services.util.XMLException)1 Guid (com.iplanet.ums.Guid)1 PersistentObject (com.iplanet.ums.PersistentObject)1 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)1 IdRepoException (com.sun.identity.idm.IdRepoException)1